subbu.org

HTTP, REST and some Cycling

JSON as a General Purpose Alternative?

with 3 comments

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.

Written by subbu

January 4th, 2007 at 10:30 am

Posted in Web Services, xml

Tagged with

3 Responses to 'JSON as a General Purpose Alternative?'

Subscribe to comments with RSS or TrackBack to 'JSON as a General Purpose Alternative?'.

  1. 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]

    Zach Smith

    5 Jan 07 at 8:49 am

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

    [Reply]

  3. 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]

    subbu.org

    30 Jan 07 at 8:42 pm

Leave a Reply