When to prefer JSON over XML?

后端 未结 19 1589
无人共我
无人共我 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 00:58

    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).

提交回复
热议问题