Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jdalton opened this issue Jan 30, 2012 · 2 comments
Closed

Comments

@jdalton
Copy link

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
Copy link
Author

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.

@douglascrockford
Copy link
Owner

Then don't do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants