json3 icon indicating copy to clipboard operation
json3 copied to clipboard

JSON.stringify is not a function

Open alexkappa opened this issue 8 years ago • 2 comments

Hello,

I am having a strange issue with JSON.stringify when using browserify. Most times it works as expected, while I get an Uncaught TypeError: JSON.stringify is not a function error on certain pages of a website.

I suspect that window.JSON is somehow modified by another script running in the same page, but I thought that using require and browserify I could scope my own JSON object to use locally hopefully not affecting other definitions, or other scripts affecting mine.

For more context, here's how I use it:

var JSON = require('json3');

var MyObject = module.exports = function() {}

MyObject.prototype.doSomething() {
   // JSON.stringify({...})
}

Should I use the runInContect or noConflict helpers that were released recently? Have I missed something entirely?

Your help is much appreciated 😃

alexkappa avatar Oct 06 '16 12:10 alexkappa

Same here!

maccman avatar Mar 20 '18 18:03 maccman

I have this issue in Firefox and Safari but not in Chrome.

aleksei-a-savitski avatar May 15 '18 16:05 aleksei-a-savitski