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

Jsonize NaN and Infinity as strings #97

Closed
wants to merge 1 commit into from

Conversation

loichuder
Copy link
Collaborator

Current approach

The treatment of NaN and (-)Infinity implemented in f427b2e serialize them as null to get valid JSON.

This raises the following problems:

What this PR does

It implements the approach described by @kgryte in #22: NaN and (-)Infinity are serialized as strings. This allows a front-end consumer to distinguish between the two and use a reviver to parse it to the desired value (e.g. Number.NaN or Number.POSITIVE_INFINITY in JS).

@loichuder
Copy link
Collaborator Author

Closing in favour of #110

@loichuder loichuder closed this Sep 3, 2021
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

Successfully merging this pull request may close these issues.

1 participant