2

I have some JS that runs fine in FF and IE but in Chrome I see the following error:

uncaught exception ReferenceError: JSON is not defined

I presume I need to include something but I'm not sure what. Help? Also, any clue why this might work on IE/FF but not Chrome?

Btw, I'm using JSON.stringify() in my script.

UPDATE: JSON.stringify is now available in chrome (couldn't find when it was introduced).

1 Answer 1

9

The JSON object is not yet part of the standard IIRC, but is expected to be soon. In the meantime, browsers are free to implement it at will, and that's probably what you are seeing here.

Your best bet is to get a separate library that does the same thing and use it for the meantime until native implementations are more widespread. You can find a very good one here (Link at the bottom).

Sign up to request clarification or add additional context in comments.

4 Comments

Specifically, I believe only FF3.5 and IE8 currently implement it.
So for FF3.5 and IE8, would the built-in implementation win or would the included js be used? Just curious how it works for JS in general...
The js file sniffs for existing window.JSON members and will leave them in place if present. (Could be native, could have been put there by another library.)
Chromium builds have also had native JSON support for a while.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.