Skip to content
New issue

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

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

Already on GitHub? # to your account

Float infinity and nan don't produce correct JSON representations #730

Closed
GoogleCodeExporter opened this issue Mar 25, 2015 · 1 comment
Closed

Comments

@GoogleCodeExporter
Copy link

These three examples all raise JSON parsing exceptions:

JSJsonParser parse: (Float infinity asJson).
JSJsonParser parse: ((Float infinity * -1) asJson).
JSJsonParser parse: (Float nan asJson).

There is no way to represent these Float values as-is in JSON. The stringify 
function in the JSON object specified in ECMA-262 section 15.12.3 simply 
outputs them as “null”, as explained in Note 4 in that section: “Finite 
numbers are stringified as if by calling ToString(number). NaN and Infinity 
regardless of sign are represented as the String null.” See 
http://ecma-international.org/ecma-262/5.1/#sec-15.12.3

Original issue reported on code.google.com by k...@yesplan.be on 8 Jun 2012 at 9:55

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant