When to prefer JSON over XML?

后端 未结 19 1634
无人共我
无人共我 2020-11-28 00:31

My requirement is just to display a set of values retrieved from database on a spread. I am using jquery.

19条回答
  •  清歌不尽
    2020-11-28 01:04

    Considering your specific case where you're already doing javascript on the client side, I'd go with JSON for these reasons:

    • Since JSON is native to javascript you'd have to write less code on the client side - Just eval() (or, better yet, JSON.parse()) the JSON string and get an object you can use.

    • At the same time evaluating JSON on the client-side will be more efficient, and therefore faster.

    • JSON serialization produces shorter strings than XML. Using JSON will reduce the amount of data running across the wire and improve performance in that respect.

    Here's some further reading: http://www.subbu.org/blog/2006/08/json-vs-xml

提交回复
热议问题