Skip to content

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

@GoogleCodeExporter

Description

@GoogleCodeExporter
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 [email protected] on 8 Jun 2012 at 9:55

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions