Replacing XML with JSON in Ajax: Is it ready?
It has simple message format: JSON message is constructed using very simple data types and data structures similar to those available in most of the programming languages. JSON has objects and arrays. Objects are collections of Named value pairs while arrays are ordered lists of values. A value can be a string, a number, a boolean (true or false), null or an object. This message format makes easier for Ajax to access the data.
var obj = eval( '(' + returned_json_text
+ ')' ) . This is fast and easy. Moreover, supported by most of the browsers and Ajax based tools.
Momentum: Though, neither JSON nor Ajax is conceptually new, in last couple of years both in general but Ajax in particular got a momentum. Ajax has provided a way to implement web based rich client. Ajax become mainstream with Google’s backing which provided Ajax based search (http://code.google.com/apis/ajaxsearch/) and toolkits (http://code.google.com/webtoolkit/). Other companies like Yahoo too entered quickly into the foray (http://developer.yahoo.com/maps/ajax/). In December 2005 Yahoo published JSON based web services (http://developer.yahoo.com/common/json.html) while Ebay provided XML2JSON transformer (https://json-xslt.codebase.ebay.com/).
Is it ready? While we witness a momentum, the real question is what do we need to make it end to end working? Do we have adequate tooling? What is the benefit? Is it worth? Is it robust? Secured?
Over last decade, a much more mature and robust infrastructure has been build around XML. In contrast with it, most of these JSON based tools/libraries are open-source and, as of today, may not be well supported. You may use them at your own risk. That’s one drawback JSON has. It lacks tooling support and standardization for different language mapping. In Java world, do we need a JSR? However, I hope that some of these open sources may become Apache projects and start evolving towards standards or become de facto standard. It all depends on how much industry support JSON gets in Ajax world.
Security, and robustness are next issues that need to be addressed. Since JSON code may carry security risk particularly due to JSON text may carry Java scripts dynamic script tag. Heavy-duty JSON applications reveal browser specific issues like memory leaks.
In summary, there is a good promise with Ajax –JSON (additionally REST); you may start some internal pilot projects. However, it would need some more time and resources to mature JSON in this combination.
Introducing JSON: http://www.json.org/
Using JSON with Yahoo Webservices: http://developer.yahoo.com/common/json.html
Labels: AJAX JSON XML