PDA

View Full Version : JSON vs XML



msuresh
2 Jan 2008, 7:13 AM
We are quite confused in selecting the correct format for our project.

We are using Struts 2.0.11. We are having the following questions in our mind.
1. Which one goes well with ExtJS?
2. Which one loads faster?
3. Which one is easier to handle?
4. Any plugins to convert data objects to JSON in Struts.

If you have any answers please let us know.

Thanking you,
SURESH M R

Collin Miller
2 Jan 2008, 8:10 AM
Both go just fine with Ext.

JSON is a lighter-weight format and could theoretically be faster in both construction, transfer and parsing, but unless you have massive data sets I wouldn't count on noticing the difference.

I find JSON easier to think about because the XML will have to be converted to a javascript object anyway. It's just one less step to wrap my head around.

I don't know about the situation in struts.

Animal
2 Jan 2008, 9:21 AM
I prefer JSON because it's just javascript source code. It's just parsed by the browser's javascript engine into an object. There's no intermediate XML parsing and then extraction from XML document into an object.

And you can pass data as what it is. Eg for a date, I use



modified: new Date(100200399300)


The number is not correct, but you get the idea. Values are all strings in XML and need interpreting into the correct final object type, but you can create JSON to contain the data in the form that your Javascript needs it.

tolstoj
2 Jan 2008, 11:40 AM
Here is a summary of earlier debates:

http://ajaxian.com/archives/json-vs-xml-the-debate

Cheers
Thomas