Skip to content

tyilo/JSON_with_NaN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

JSON with NaN (and Infinity/-Infinity)

Even though JSON is supported out of the box in modern browsers, none of them supports NaN, Infinity or -Infinity as values in JSON. This is because the JSON spec doesn't allow these values.

However sometimes it is useful to be able to pass all Javascript numbers around, so this project solves the problem by providing the functions JSON.stringifyWithNaN and JSON.parseWithNaN.

Strings created with JSON.stringifyWithNaN should be compatible with Python's json module with allow_nan=True (which is the default).

Usage

JSON.stringifyWithNaN(value[, replacer[, space]])
JSON.parseWithNaN(text[, reviver])

See the MDN article for JSON.stringify and JSON.parse for more information about the parameters.

About

JSON with NaN (and Infinity/-Infinity)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published