-
Notifications
You must be signed in to change notification settings - Fork 34
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
Float nan
values are generated in JSON
#93
Comments
NaN is not a valid number in json, so I will not parse it. If you are expecting to get NaNs some times you could make a parseHook and parse them yourself. |
As it should be, but this issue is about jsony creating nans when converting an object to a JSON string |
Here's a small reproduction: import jsony
type m = object
test: string
field: float
echo m(test: "Hello world", field: Nan).toJson which produces:
Notice how |
For reference in Python there is an allow_nan parameters that allows to output nans (and infinity values). If set to False it would raise an error when serializing an non number value. https://docs.python.org/3/library/json.html#basic-usage |
Sorry this is indeed a real issue. |
Had an issue recently where
NaN
values from Nim got written to JSON asnan
. According to the official JSON specnan
is not a valid value in JSON. Not quite sure what the actual behaviour here should be. I see thatjq
parses such JSON fine, but NimsparseJson
fails.The text was updated successfully, but these errors were encountered: