Difference between json.js and json2.js

前端 未结 3 1534
不思量自难忘°
不思量自难忘° 2020-12-12 14:24

Can someone tell me what the difference is between the 2 JSON parsers?

https://github.com/douglascrockford/JSON-js/blob/master/json.js
https://github.com/douglas

3条回答
  •  时光说笑
    2020-12-12 14:36

    I also noticed that json2 stringified arrays differently than json2007.

    In json2007:

    var array = [];
    array[1] = "apple";
    array[2] = "orange";
    alert(array.toJSONString()); // Output: ["apple", "orange"].
    

    In json2:

    var array = [];
    array[1] = "apple";
    array[2] = "orange";
    alert(JSON.stringify(array)); // Output: [null, "apple", "orange"].
    

提交回复
热议问题