PHP: is JSON or XML parser faster?

后端 未结 6 2002
暗喜
暗喜 2020-12-06 16:36

I\'m building classes that interface with the Twitter API, and I\'m wondering whether PHP\'s built-in XML or JSON parser is faster? Twitter will send me the same data in eit

6条回答
  •  一向
    一向 (楼主)
    2020-12-06 17:20

    I tend to find that simplexml_load_string() is faster than json_decode() when the json return is an object.

    However, having the json returned as an array using json_decode($string, true) is actually a lot faster than using an object (as is true with most things PHP when comparing arrays to objects).

    Ive seen json_decode() being over twice as fast as simplexml_load_string() under these circumstances.

提交回复
热议问题