Is parsing JSON faster than parsing XML

前端 未结 11 704
盖世英雄少女心
盖世英雄少女心 2020-12-01 04:51

I\'m creating a sophisticated JavaScript library for working with my company\'s server side framework.

The server side framework encodes its data to a simple XML for

11条回答
  •  -上瘾入骨i
    2020-12-01 05:31

    Benchmarks have been done. Here's one. The difference in some of the earlier browsers appeared to be an entire order of magnitude (on the order of 10s of milliseconds instead of 100s of ms), but not massive. Part of this is in server response time - XML is bulkier as a data format. Part of it is parsing time - JSON lets you send JavaScript objects, while XML requires parsing a document.

    You could consider adding to your public API a method to return JSON instead of modifying existing functions if it becomes and issue, unless you don't want to expose the JSON.

    See also the SO question When to prefer JSON over XML?

提交回复
热议问题