jmav
jmav

Reputation: 3149

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/js.html.

Upvotes: 7

Views: 2919

Answers (3)

jmav
jmav

Reputation: 3149

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.

Upvotes: 0

Christian C. Salvadó
Christian C. Salvadó

Reputation: 827536

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...

Upvotes: 3

Alex Sexton
Alex Sexton

Reputation: 10451

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.

Upvotes: 4

Related Questions