Why JSON? One word: Simplicity.
More than one word: JSON is simple, simpler than Xml. I am big fan of Xml, and that makes me a love XPath as well. But this does not mean that I am against JSON or otherwise. While on my way back home the other evening, this guy who works in the IT department of one of my customer, where I was for the project implementation. While he was talking to "his" friend(colleague, probably) about JSON and Xml, and if Xml is there then why would you ever use JSON? I was sort of magnet'ically attracted to the discussion and eventually became the part of it. So, here I thought I should add my two cents of understanding of how and where I would use either and what would be the use case.
Xml is more "documented" oriented, has its own defined format; you may use Xml in cases where structured documents are required - and that with a large amount of data. While JSON is more like "data oriented", which makes JSON handy for lightweight data exchange.
The purpose of JSON and Xml may be the same - data exchange; but the usage scenario for each is different. For instance you cant use a mallet, where a ball-pein is required.
- Similar to Xml human/machine readable format
- Both has support for Unicode
- "Self-documenting format" - that is, describes the structure, fields, and values
- Mostly used in cases where you have to maintain a list, or arrays, or trees, or records.
This could mean that JSON may become handy and lightweight way of data exchange if you think about how to use it within jQuery based AJAJ calls.
Some of the things that people take as benefit is that, to avoid name conflicts Xml has namespaces; while in JSON there is no namespace; but the URI that you fetch the JSON document from implicitly becomes the namespace.
With Xml you have to think 'DOM'ically; but in JSON the data is plain, simple and easy to read.
JSON does not support data validation; is not extensible.
So, conclusion - whatever you use, choose it based upon what is required.
So if you do like JSON, chances are that you would like the YAML.
References and must reads: