开发者

Does jQuery have built in full support for JSON2?

I need to know is JSON2 lib included in jQuery core or must i use JSON2 lib from http://www.json.org/j开发者_JAVA技巧s.html.


It is not included in the current jQuery core (1.3.2). In the jquery irc #jquery on freenode, there is a quote by John Resig:

John Resig: "In the meantime PLEASE start migrating your JSON-using applications over to Crockford's json2.js"

Future versions of jQuery are planned to support this natively.


JSON2 is not included on the jQuery Core, but if you are wanting to use jQuery to get JSON responses from your server (by using $.getJSON, and other Ajax functions with dataType = "json") jQuery will evaluate the JSON for you, you don't need anything more.

If you need other things, like stringifying objects or parsing JSON strings on your own, you will need the JSON2 library...


jQuery 1.4.1 have native support for parsing JSON at: http://api.jquery.com/jQuery.parseJSON/.

Additionally if you pass in nothing, an empty string, null, or undefined, 'null' will be returned from parseJSON. Where the browser provides a native implementation of JSON.parse, jQuery uses it to parse the string.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜