开发者

JSON2.js or Native JSON Methods

JSON MDC

JSON ORG

Since the addition of the JSON 开发者_JAVA技巧methods(parse, stringify) listed at the Mozilla site, should these methods be used in lieu of the files from JSON.org(json2.js)?


You should use the native functions as they will get better performance and have a better memory footprint. Consider json2.js to be a polyfill, something you only use if the browser doesn't support JSON. A list of these browsers can be found here: http://caniuse.com/#search=JSON

if(!JSON || !JSON.parse || !JSON.stringify)
    document.write('<script src="json2.js"></script>');


Yes. Various javascript libraries already ask for native browser support before running parser in javascript. You can do it yourself by asking if there is global JSON object defined.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜