function parseJson(json) { let out; try { if (typeof JSON == 'object' && typeof JSON.parse == 'function') { out = JSON.parse(json); } else { out = eval('('+json+')'); } } catch(e) { // do nothing } return out; }
Programming Tips - javaScript: parse JSON in any browser
Date: 2009dec22
Language: javaScript
Warning: Now, I would recommend using jQuery to parse JSON
Q. javaScript: parse JSON in any browser
A. Many browsers have a JSON.parse() function which is the best thing
to use. But not all. So use this function: