JSON as a General Purpose Alternative?

by Subbu Allamaraju on January 4, 2007

The discussion at Dare Obasanjo’s blog, and the references to some other recent posts motivate me to look at some of the broader arguments being made. It is clear that processing JSON data using JavaScript is trivial, and that is what makes JSON a popular alternative over XML currently. All other advantages and disadvantages over XML are incidental. If we take out JavaScript from the picture, JSON is not a clear winner. Both JSON and XML take some effort to parse and process outside JavaScript.

Unfortunately, some in the industry are missing this point, and concluding that JSON is a clear winner over XML for other reasons such as being a simpler format, faster and so on. For instance, in his post JSON and XML, Tim Bray seems to be favoring JSON because “JSON’s single prpose design is to put struts on the wire” That’s not why web developers favor JSON over XML. It is the complexity of processing on the browser, and JSON makes it trivial.

I tend to agree with Don Box, who commented that “JSON has a huge hill to climb to displace XML for new applications that don’t already have a JavaScript/browser component”. We need some more serious efforts to simplify JSON creating/parsing in languages other than JavaScript to make JSON more general-purpose than it is today. Although there is no information that can be represented in an XML document that cannot be represented in a JSON document, it does not mean that all new applications should switch from XML to JSON. For now, if a browser is the consumer of the data, consider JSON over XML.

{ 5 comments… read them below or add one }

1 Zach Smith January 5, 2007 at 8:49 am

I think the major thing that people are missing with JSON vs XML is that there are many, many libraries that do encoding and decoding. The thing I personally love about JSON is that i can pass around data structures… without caring how they are represented!! One encode call on the server, a decode call on the client and then I’m back to directly accessing the data. IMHO, that is the true advantage of JSON. The other things like it being lightweight, javascript friendly, etc are just side benefits

Reply

2 Subbu Allamaraju January 5, 2007 at 11:17 am

Zach – the key point is that, outside Javascript/browser world, passing structs as JSON data does not make much sense.

Reply

3 subbu.org January 30, 2007 at 8:42 pm

JSON Wars Continue

JSON vs XML wars are still going on, and they are becoming more amusing, I must say. The latest is from Sean McGrath arguing about the significance of mixed content in XML….

Reply

4 Simon Occoner July 4, 2010 at 3:34 pm

actually i came accross something a data interchange format called ENTITY.
so its seems its JSON vx XML vs ENTITY.

Reply

5 Simon Occoner July 4, 2010 at 3:35 pm

see for yourselfs this is the site i think.
http://www.entity-format.co.uk

Reply

Leave a Comment

Previous post:

Next post: