It appears that some code/library has overridden the global JSON object. JSON.toStr
is fine but if you want the original JSON
objet back you can always create an invisible frame and use its global objects
OriginalJSON = (function() {
var e = document.createElement('frame');
e.style.display = 'none';
var f = document.body.appendChild(e);
return f.contentWindow.JSON;
})()
OriginalJSON.stringify({a: 1})
This is a technique that works for all global objects that has been overridden for some reason. As an alternative you can always copy only the stringify
method
JSON.stringify = (function() {
var e = document.createElement('frame');
e.style.display = 'none';
var f = document.body.appendChild(e);
return f.contentWindow.JSON.stringify;
})()
// Now JSON.stringify is back
JSON.stringify({a: 1})