My requirement is just to display a set of values retrieved from database on a spread. I am using jquery.
Usually JSON is more compact, and faster to parse.
Prefer XML if:
One important case of (almost) XML: try to detect when sending HTML snippets is more beneficial than sending raw data. AHAH can do wonders in simple applications, yet frequently overlooked. Usually this style assumes that a server sends HTML snippets that will be inlined in the web page without processing.
Usually in AHAH cases CSS is being leveraged to the max to massage snippets visually and implementing simple conditionals like hiding/showing relevant parts of the snippet using user-specific or application-specific settings.
JSON is always preferable in terms of the processing the client browser has to do for parsing the data. Also, JSON is light weight data exchange format.
XML parsing always consumes lot of browser resources and should be avoided as much as we can unless otherwise required.
Both XML and JSON are supported by Microsoft. XML literals were the new cool feature in VB 9. In the upcoming version of ASP.NET 4.0 JSON is a must to leverage the power of client side templating.
From the question you have asked it seems JSON might be the choice for you as it is easy to process on client side with or without jQuery.
JSON is easy and faster to parse. XML is a little more difficult to parse, and is slower to parse and transfer (in most cases).
Since you're using jQuery, I suggest using JSON: jQuery can retreive JSON data and convert it into a Javascript object automatically. In fact, you can convert JSON data into a Javascript object using eval. XML would have to be transversed manually by you (I don't know how this works in Javascript, but it's difficult/more annoying in most languages I've used XML libraries with).
Some other things that I have run into in the XML vs JSON relm:
JSON is very good for
Which means it tends to like an array or nested array. However JSON is missing both
So if you were to combine two or more JSON services there could be potential namespace conflicts. That being said JSON can be used for about 90% of the same things XML can be used for when exchanging data in my experience.
Favor XML over JSON when any of these is true:
Favor JSON over XML when all of these are true: