7

I need to know is JSON2 lib included in jQuery core or must i use JSON2 lib from http://www.json.org/js.html.

jmav
  • 3,119
  • 4
  • 27
  • 27
  • What is JSON2? What is the difference between it and JSON? – Marius Oct 19 '09 at 07:45
  • 1
    http://stackoverflow.com/questions/552135/difference-between-json-js-and-json2-js – jmav Oct 19 '09 at 08:25
  • jquery does have a json plugin (as a plugin, it's a separate file), since 2008. here are some words from its creator: http://stackoverflow.com/questions/3979649/json2-vs-jquery-json/4183971#4183971 – cregox Mar 17 '11 at 18:48

3 Answers3

4

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.

Alex Sexton
  • 10,401
  • 2
  • 29
  • 41
  • This information is stored in the #jquery bot on irc.freenode.net which is where John gave this information (at least one of the places). So there is no direct link. You can, however, query the bot very easily. Log into #jquery and type the command: `?json2` (no backticks, of course) and you will get that quote along with a link to the library. – Alex Sexton Oct 19 '09 at 08:42
  • Ah yes, it also seems to be in his blog. :D Here is the link for the feature request for 1.3.3 - which is now 1.4 : http://dev.jquery.com/ticket/4990 – Alex Sexton Oct 19 '09 at 08:47
3

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

Christian C. Salvadó
  • 807,428
  • 183
  • 922
  • 838
0

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.

jmav
  • 3,119
  • 4
  • 27
  • 27