What is JSON?
Some examples of XML and its equivalent JSON as given below:
XML: <xx yy='nn'><mm>zzz</mm></xx>
JSON: { "xx": {"yy":"nn","mm":"zzz"}}
XML: <xx yy='nn'><mm>zzz</mm><mm>aaa</mm></xx>
JSON: { "xx": {"yy":"nn", "mm":["zzz","aaa" ] } }
XML: <xx><mm>zzz</mm>some text</xx>
JSON: { "xx": {"mm":"zzz", "value":"some text"} }
XML: <xx value='yyy'>some text<mm>zzz</mm>more text</xx>
JSON: { "xx": {"mm":"zzz", "value":[ "yyy", "some text", "more text" ] } }
JSON to XML and XML to JSON Converter
James Newton-King has created an excellent library for JSON conversion in C#. The library has following features:
- LINQ to JSON
- The JsonSerializer for quickly converting your .NET objects to JSON and back again
- Json.NET can optionally produce well formatted, indented JSON for debugging or display
- Attributes like JsonIgnore and JsonProperty can be added to a class to customize how a class is serialized
- Ability to convert JSON to and from XML
- Supports multiple platforms: .NET, Silverlight and the Compact Framework
You can download the JSON C# library here. More information about the JSON Utilities library can be found at http://james.newtonking.com/projects/json-net.aspx.
Hats off James, this is an excellent work!