Querying JSON with JSON Path and escaped properties
April 6, 2024 ยท View on GitHub
This sample loads JSON with properties that need to be escaped when queried with Argon.JToken.SelectToken(System.String).
var o = JObject.Parse(
"""
{
'Space Invaders': 'Taito',
'Doom ]|[': 'id',
"Yar's Revenge": 'Atari',
'Government "Intelligence"': 'Make-Believe'
}
""");
var spaceInvaders = (string) o.SelectToken("['Space Invaders']");
// Taito
var doom3 = (string) o.SelectToken("['Doom ]|[']");
// id
var yarsRevenge = (string) o.SelectToken("['Yar\\'s Revenge']");
// Atari
var governmentIntelligence = (string) o.SelectToken("['Government \"Intelligence\"']");
// Make-Believe