Click or drag to resize
Json.NET

Querying JSON with JSON Path and escaped properties

 

This sample loads JSON with properties that need to be escaped when queried with SelectToken(String).

Sample
Usage
JObject o = JObject.Parse(@"{
  'Space Invaders': 'Taito',
  'Doom ]|[': 'id',
  ""Yar's Revenge"": 'Atari',
  'Government ""Intelligence""': 'Make-Believe'
}");

string spaceInvaders = (string)o.SelectToken("['Space Invaders']");
// Taito

string doom3 = (string)o.SelectToken("['Doom ]|[']");
// id

string yarsRevenge = (string)o.SelectToken("['Yar\\'s Revenge']");
// Atari

string governmentIntelligence = (string)o.SelectToken("['Government \"Intelligence\"']");
// Make-Believe