Some code that I don’t have control over is overriding the global JSON object without checking if it’s already implemented:
var JSON = {
org: "http://www.JSON.org",
copyright: "(c)2005 JSON.org",
license: "http://www.crockford.com/JSON/license.html",
stringify: function(a, g) {
...
The problem is that this version of the JSON parser is very old and has a bug, which is fouling up my attempts at serialization. (Others have had a similar problem with this implementation.)
Can I get at the browser’s native implementation? I thought delete would work, but it doesn’t. I suspect that’s because JSON is an object and not a method in the prototype. Is there some other way to get at it?
You can create an
iframeelement (which will loadabout:blankand hence create a new context) and get a JSON object from there.about:blankis loaded synchronously, so no need to wait for theloadevent. While this isn’t restoring the original JSON object, it is getting one black-box identical to it.