-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
encoding/json: unsupported value: NaN #25721
Comments
@mvdan yes I did, and I'm aware that it is pretty messy issue, but IMO just having to deal with NaN being either NaN, inf+ or inf- is better than having ser/des of one document fail because of single (and, currently, hard to find) NaN. From my experience with other libs in other languages most of them just chose to break strict adherence to JSON And currently Go is also breaking the standard, just in other way, err'ing out when it should just return string "null", and err'ing out on ingestion with no option to opt out. Maybe adding additional struct options would help? Like:
|
Closing this as a duplicate of #3480. You can open a proposal for your suggested change, or you can file a separate issue for improving the error message. |
Just create your own custom decoder (and encoder too if nec.) |
Bot closed the previous issue ( #3480 ), just reminding problem still exists
What version of Go are you using (
go version
)?go version go1.9.2 linux/amd64
Does this issue reproduce with the latest release?
It does with go playground
What did you do?
Same as #3480
https://play.golang.org/p/K4xwS7iy4MP
What did you expect to see?
Not throwing serialization errors on basic numeric data types with valid state
What did you see instead?
json: unsupported value: NaN
Which is by the way very uninformative and badly written error message as it doesn't show which key showed that error which just makes hunting the source of NaN utter pain in arse
The text was updated successfully, but these errors were encountered: