plainJS

Functions / Utilities

Parsing a JSON string

jQuery $.parseJSON()

2015 page

This is the original page from 2015, kept at its address while the tested rewrite is in progress. The code is of its time: it ran in Internet Explorer and does not use what browsers have gained since. The rewrite replaces it here.

In short

Takes a well-formed JSON string and returns the resulting JavaScript value.

Use this fast and reliable method that is available in all modern browsers, including IE 8 to replace jQuery’s $.parseJSON:

js
var json = '{ "foo": true, "bar": 1 }',
    obj = JSON.parse(json);

console.log(obj);