Is there a JSON parser for .NET 4.0?
Ideally something like:
String jsonText = GetTheJsonFromTheInternet();
var json = JsonValue.Parse(jsonText);
and now i have a nested set of key-value pairs.
Use JSON.net
What i dont want, is to have to create a set of objects to match the JSON. i asking about parsing JSON, not deserializing JSON. You can pretend it's because i don't know the structure of the JSON.
Similar to how you parse XML:
String xmlText = GetTheXmlFromTheInternet();
XmlDocument doc = new XmlDocument();
doc.LoadXml(XmlText);
and now i have a nested set of names-values-attributes. You don't create objects to represent the XML DOM tree; you parse a string of XML and now it's easy to navigate and find things.
Why not just use JsonValue.Parse()?
Because:
- JsonValue (found in
System.Json.dll) was not available until .NET Framework 4.5. - and Visual Studio 2010 cannot target .NET Framework 4.5. (only Visual Studio 2012)
- and Visual Studio 2012 requires Windows 8
And writing my own JSON parser would take a few days (to get it correct and good).
i've gone through the JSON.net documentation. i can't tell if it supports JSON parsing.