1

I was curious if anyone here had a preference or if one library should definitely be used over the other? It seems that Json2.js is the "de-facto" standard. But JQuery-json is a jquery plugin. And since I'm using JQuery, I wondered which one should I be using.

JQuery-json and Json2.js

dotnetN00b
  • 5,021
  • 13
  • 62
  • 95

2 Answers2

2

I'd suggest using Json2.js because it's a direct polyfill of the browser standard.

The JSON object is a built-in feature for all modern browsers. The only reason we need to use scripts like Json2.js is to support older browsers such as old versions of IE that don't have it built in. The syntax it provides is identical to the built-in JSON object in other browsers, and it doesn't override the built-in object if it already exists.

JQuery also uses the built-in JSON object where it's available as well, so at the end of the day, it's pretty much doing the same thing, but for browsers that already have the JSON object, using jQuery to wrap it means you're adding a layer of unnecessary syntax. You may or may not care about this, but that's pretty much the difference between them.

SDC
  • 14,192
  • 2
  • 35
  • 48
1

jQuery has had native JSON support for ages. Don't use a plugin for it.

Use json2.js if you aren't already using jQuery or another library that provides JSON support in old browsers.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335