Skip to content

Incorrect results if `Date#toJSON` is specified but not the `JSON` object. #28

jdalton opened this Issue Jan 30, 2012 · 2 comments

2 participants

jdalton commented Jan 30, 2012

I noticed that if I include json2.js on a page that doesn't have the JSON object but does have Date#toJSON specified I get incorrect output from JSON.stringify().

Here is a simple example:

JSON.stringify(Object('hi')); // should return '"hi"' but returns '{"0":"h","1":"i"}'
jdalton commented Jan 30, 2012

I also noticed it happening if a script on a page removes the non-spec'ed String#toJSON method that json2.js adds.


Then don't do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.