开发者

Differences/Advantages of using JSON over XML or vice versa? [duplicate]

This question already has answers here: 开发者_运维问答 Closed 12 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜