Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Json2/Json3 library required still?

Quick question. Is there any need to include the Json2 library anymore? Did I read somewhere that JavaScript supports JSON as standard these days so there's no need to parse it anymore?

Any advantages or disadvantages to Json2 vs standard JavaScript support?

like image 998
Liam Avatar asked Mar 16 '12 11:03

Liam


1 Answers

JSON was standardised in ECMAScript 5, so browsers that conform to that specification include JSON, but others browsers don't (such as those that were released before ECMAScript 5/ IE). If you need to support these browsers, you still need to include it.

Specifically, JSON was introduced in:

  • IE8,
  • FireFox 3.5 -
  • Opera 10.5.
  • Chrome (1) (AFAIK)

json2.js checks whether JSON.parse is already implemented, and only provides it's implementation if it doesn't; so think of it as a sort of polyfiller for older browsers.

Sources: http://kangax.github.com/es5-compat-table/, http://caniuse.com/#feat=json

like image 117
Matt Avatar answered Oct 04 '22 08:10

Matt