I have been keeping a track of JSON (JavaScript Object Notation) versus XML for the past couple of months when AJAX came up as a big bang approach. Arun Gupta also recounts his similar experience with the XML JSON debate and concludes,

XML is document-oriented and JSON is data-oriented. So if you want to deal with highly structured documents that requires a complex structure, binary data, exact ordering of elements and be able to render itself then use XML. If you are focused on light-weight data exchange then JSON is the way to go.

In my opinion too JSON is handy only for light weight data transfer and nothing more than that. But with more nesting of data JSON can get utterly complex than XML. With XML you can define Schemas, form standardized document structures , extend exisiting document structures or import them when needed. The namespaces concept of XML has been very well established and incorporated in today’s applications and libraries.

XML Dominance
XML got more acceptance due to the already well established markup languages like HTML. Due to standardization by W3C it got quickly incorporated into the big vendors tools. Even a well documented JSP is purely XML. The main advantage of XML success is the XML Schema defintion language (XSD) which has given rise to numerous other standards like SOAP, WSDL etc. It is a very flexible and extensible language.

If you look behind the scenes a bit, XML has been reigning from the past and its usage in the industry has become massive. You might not be aware but all the big applications use XML either for storage, transfer, presentation or configuration of data and also meta data. MS SQL uses XML to transfer data from one database to other. MS WORD uses XML to provide formatting of user input content in the documents.

JSON- Some Facts
Coming back to JSON, the main fact which goes against JSON is it is not standardized. But now if JSON wants to establish its presence then the only field in my opinion would be SOA web services and AJAX where, it has received a lot of attention. Lately the debate on using web services with JSON has started. XML being heavy puts somewhat a hindrance on the acceptance of web services since the network infrastructure needs to get upgraded to get quicker adoption of XML RPC web services. With JSON, if web services give a higher throughput then it might be time to cash upon its acceptance for data transfer. Alexander writes about JSON pros and cons in his blog MyArch,

One of the keys to SOA success is that it should be easy to consume a service, i.e., the entry barrier for service consumers must be low to support “grass root” SOA adoption. While a top-down SOA effort may succeed, it will certainly take longer than bottom-up (“grass-root”) approach when developers are able to consume services as they see fit. AJAX/JSON fits this bill perfectly – it is easily understood by developers and it does not require any Web services -specific tools or infrastructure.So overall I’m pretty enthusiastic about JSON.

Advantages of JSON
The advantage of using JSON instead of XML is in the inheritent quality of data structuring in JSON. JSON is more closer to being a HashMap as in java or an associative array in some other languages like PHP. Hence it does not require parsing libraries in an application as XML does. The time spent however, on parsing XML into the native language, is not so much significant considering the fast processing power of machines today.

The comparison of XML and JSON lies more on the network bandwidth aspect. JSON can take almost half of the bandwidth as XML for transferring the same data. It can achieve the same throughput as passing simple objects in the network in a distributed computing environment.

JSON Web Services?
It would be interesting to see how would a SOAP message with JSON look like. You have to remember that WSDL is an extensible language and till date only HTTP Bindings and SOAP Bindings have been defined for it. It wont be long before we see JSON Bindings coming into the WSDL documents. Who would not want a quick data transfer while using web services into the application?

AJAX with JSON has got accepted well since JavaScript has the inbuilt capability to handle JSON data and if JSON web services start getting acceptance it might get well flourished to reach the popularity charts as XML did. Is the web service industry looking for a paradigm shift or are we just building a castle in the air?

Stumble Digg Technorati Subscribe Delicious