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

NaN encoded as 2.696539702293474e308 #509

Closed
stepelu opened this issue Jan 19, 2016 · 4 comments
Closed

NaN encoded as 2.696539702293474e308 #509

stepelu opened this issue Jan 19, 2016 · 4 comments

Comments

@stepelu
Copy link

stepelu commented Jan 19, 2016

I am aware that NaNs are not part of the JSON standard and I am not advocating adding the ability to encode/decode them.

However, currently NaNs are silently encoded as 2.696539702293474e308 which is very error prone.
It would be preferable to have an error thrown in Writer::Double() if a NaN is passed.

@miloyip
Copy link
Collaborator

miloyip commented Jan 19, 2016

Yes. This is not currently checked.

With the current bool WriteDouble(double d) API, I can make it return false if d is either NaN or infinity.

@stepelu
Copy link
Author

stepelu commented Jan 20, 2016

Thanks for the prompt fix!

While Nans should be checked, I am unsure about the Inf case.
I am actually able to get them forth and back correctly, do you have any opinion on the matter?

@miloyip
Copy link
Collaborator

miloyip commented Jan 20, 2016

I don't think it is able to make a roundtrip for +/-inf.
#36 has proposed to add relaxed JSON syntax for NaN/though.
If you think #510 is OK, I will merge it.

@stepelu
Copy link
Author

stepelu commented Jan 20, 2016

Yes, it is fine with me, thank you.

On 20 January 2016 at 12:23, Milo Yip notifications@github.com wrote:

I don't think it is able to make a roundtrip for +/-inf.
#36 #36 has proposed to add
relaxed JSON syntax for NaN/though.
If you think #510 #510 is OK,
I will merge it.


Reply to this email directly or view it on GitHub
#509 (comment).

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

No branches or pull requests

2 participants