Thursday, June 1, 2006

About JSON and poor marketing strategies

OPS 3.x Logo

I am writing up a bit about JSON for our upcoming Web 2.0 book. I had heard of JSON for quite a while, but I have now taken the time to read the short spec at

In fact, I quite like the idea of JSON. It appears quite elegant, simple, concise, readable, easy to parse, and as an alternative to XML for Ajax, I am ready to seriously consider it in some situations.

But I have to say that the way JSON is compared to XML on the JSON web site leaves a lot to be desired. You understand the gut feeling of the author (Is it Doug Crockford, the inventor of JSON? The page doesn't say, and that's probably better for its author.) who doesn't appear to like XML as a data exchange format, but he proceeds to a rationalization of that feeling which leaves me with my mouth gaping. For example, that page claims:

  • JSON is much easier for human to read than XML. Well, that's certainly a bold claim, with which I don't agree. You have brackets in XML, you have brackets in JSON (and two types of those, one type for objects and one type for arrays). At best, my opinion is that a nicely formatted JSON document is about as readable (or unreadable) as a nicely formatted XML document, and I am comforted by these examples comparing JSON and XML. XML is going to be more verbose (elements' end-tags), but that's not an argument against readability, on the contrary. Claiming better readability for JSON is little more than wishful thinking.

  • JSON is not extensible because it does not need to be. Here there is a misconception about the extensibility of XML. XML is extensible because it lets you create your own element and attribute names and document structure. The same goes for JSON, since you can name your objects arbitrarily and create your own structure as well. The edge that XML would have over JSON here is that it supports namespaces, which JSON doesn't support. Now that JSON doesn't actually need namespaces, I don't know. Again, that's a bold claim. Remember, XML started without namespaces too!

  • JSON is a better data exchange format. Says who? The inventor of JSON. Based on what exactly? I am not sure, and that's just another bold claim.

  • JSON does not provide any display capabilities because it is not a document markup language. Who said that XML provides "display capabilities"? I don't know of any.

  • JSON does not have a CDATA feature, so it is not well suited to act as a carrier of sounds or images or other large binary payloads. Here you have to be puzzled. CDATA sections in XML have nothing to do with binary data. In XML like in JSON, binary data has to be encoded into text, using Base64 encoding, for example. You also learn from the JSON web site that XML can contain Java applets and ActiveX! I believe we are officially in a dream (or nightmare) now.

There is more, but I will stop for now. There is of course little chance that such a load of junk will make people think less of JSON. But certainly, I think less of the author of this comparison page because he doesn't know anything about XML and talks about it anyway. My advice to him would be to simply take that page down, or at least remove the downright ridiculous points. As a marketing strategy, you don't have to flame down XML to promote JSON, because JSON is in fact a pretty good alternative to XML in certain circumstances. Let JSON live off its actual merits, not off misconceptions about XML.

No comments:

Post a Comment