Differences/Advantages of using JSON over XML or vice versa? [duplicate]
Possible Duplicate:
When to prefer JSON over XML?
i wonder if JSON is the preferred choice for AJAX transfers (if this is what its called) over XML? i see that usually JSON is used in jQuery docs over XML?
JSON is more compact than XML and will consume less bandwidth. It is also easier to manipulate with javascript because you are working directly with objects while XML needs to be parsed.
There are a lot of sites out there with pages discussing the relative merits of the two.
This page for example, has one very good reason why you might want to use JSON over XML:
From the start, JSON is already has a leg up on XML for one reason: it’s faster. To read XML you need to parse it, read the nodes, attributes, and child nodes in the XML document, and then use the data that you’ve found.
However, with all of these questions you need to use the technology that best suits your particular problem rather than assuming that one of them can solve everything.
精彩评论