I’ve heard a lot about how JSON is far superior to XML. I’d like to play devil’s advocate to the masses and ask when is XML superior to JSON? Assuming you’re not having to worry about using XML to communicate by some legacy system or what not and you have full control over client and server, in what case would you choose XML when JSON could also work for data transmission?
Share
XML was designed originally for marking up text in documents. That’s something JSON simply can’t do.
XML has been widely adopted for a secondary role, serializing structured data into text form for messaging. That’s a job which JSON can probably do just as well. In that role, XML has an advantage because of the layers of stuff that have been built around it – schema languages, namespaces, transformation and query languages, databases etc; while JSON has an advantage because it’s simpler and is a better fit to traditional 3G programming languages.
XML is used as the basis of thousands of standardized vocabularies for particular kinds of data. Those vocabularies aren’t going to disappear in a hurry; and I don’t yet see anyone developing new industry-standard message formats using JSON rather than XML (once they do, JSON will need to add the layers of complexity that XML has accumulated). JSON, I think, is largely used today for exchanging data between two programs that were both written by the same people.