If you're new to JSON, a fair question you could ask would be: why another data exchange format? JSON, just like XML, is a text-based format that it is easy to write and to understand for both humans and computers. The key word in the definition above is "lightweight". JSON data structures occupy less bandwidth than their XML versions.
To get an idea of how JSON compares to XML, let's take the same data structure and see how we would represent it using both standards:
The same message, written in JSON this time, looks like this:
As you can see, they aren't very different. If we disregard the extra formatting spaces that we added for better readability, the XML message occupies 396 bytes while the JSON message has only 274 bytes.
value can be a
string is a collection of Unicode characters surrounded by double quotes. For escaping, we use the backslash (\).
If you plan to work with JSON data outside of the Microsoft AJAX Library, you can use the library listed at http://www.json.org/js.html.
[This is an excerpt from the book, Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained, by Cristian Darie, Bogdan Brinzarea . Published by Packt Publishing Ltd., 2007]