Closed Bug 1586720 Opened 5 years ago Closed 5 years ago

Json Parser cannot parse NaN

Categories

(Firefox :: Untriaged, defect)

60 Branch
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: jan, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36

Steps to reproduce:

I loaded json data from a website that contained NaN values.

Actual results:

Got the error "SyntaxError: Json.Parse: Unexpected character at line x column y of the JSON data.

Expected results:

Should have correctly parsed the NaN value.

JSON specs don't allow for NaN
http://json.org/

console.log( JSON.parse('{ "x" : NaN  }') );
SyntaxError: JSON.parse: unexpected character at line 1 column 9 of the JSON data

console.log(JSON.stringify({ x: NaN }));
{"x":null}
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: