- JSON is more compact and can be easily loaded in JavaScript.
- XML is stricter and has support for schemas and namespaces.
On the face of it JSON seems superior in every way - it's flexible, more compact and in many cases easier to use (especially when working with JavaScript), however it lacks some key features, in particular:
I.e. the ability for party A to specify the format of a document, and the ability for party B to check that they are supplying something that matches this format.
This is crucial when passing data between separate systems, where a deviation from the expected format might mean that the data cannot be processed (or worse, is processed incorrectly).
I.e. the ability to mix data intended to be read by multiple sources (or written by multiple sources) in the same document.
An example of this in action is the SOAP protocol - namespaces allow for the separation of the SOAP "Envelope", or "Wrapper" data which is passed alongside the serialised application data. This allows web frameworks process and handle the SOAP Envelope and then pass the body / payload data onto the application.
JSON is very useful when developing a web application where fast, compact and convenient serialisation of data is required, however it's flexible nature is the very thing that makes it less suitable than XML for transferring data between separate systems, or storing data that will be read by 3rd parties.
Perhaps in time these sorts of features will appear in JSON, but for now XML is the dominant format for things like web services and file formats.