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

Handle serialization of odd float values #1275

Merged
merged 3 commits into from
Sep 10, 2019

Conversation

mjgpy3
Copy link
Contributor

@mjgpy3 mjgpy3 commented Jul 24, 2019

Unfortunately System.Double.NaN, System.Double.PositiveInfinity and System.Double.NegativeInfinity cause invalid JSON to be generated. These seem like special cases that shouldn't happen often but they are not disallowed by the type system.

I was using FsCheck to generate JsonValue instances and I noticed an array containing NaN which causes JSON parsers to error.

This change attempts to mimic the decisions already made in JavaScript, e.g.

$ node
> JSON.stringify(NaN)
'null'
> JSON.stringify(Infinity)
'null'
> JSON.stringify(-Infinity)
'null'

@mjgpy3
Copy link
Contributor Author

mjgpy3 commented Jul 24, 2019

I just looked through the issues and it appears that this resolves #1259

@dsyme dsyme merged commit e2e329a into fsprojects:master Sep 10, 2019
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.

None yet

2 participants