-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Handling special IEEE754 values #960
Comments
@kjaquier - The jq maintainers are aware of numerous such issues that flow from certain decisions about the handling of JSON's "number" type. Bear in mind, for example, that a prime requirement of "." is that it produce valid JSON. This immediately introduces an asymmetry if invalid JSON is accepted as input. (Would you want Unfortunately there is no easy solution to all the issues related to "number", and the maintainers seem generally to take the view (or to have taken the view) that most of the issues are in practice relatively unimportant. Now that jq 1.5 has been released, however, maybe the time is ripe for devising and documenting a plan and a strategy for dealing with them. |
Thank you for your detailed response. I should have checked the standard first, it didn't even cross my mind that these keywords were not part of the standard. Makes it a quite complicated problem indeed. I personally think it would be great to have support for other common variations (simple quotes, quoteless keys and keywords for ECMAScript, |
JSON does not even have NaNs or infinities. Anyways, see many prior issues
and the wiki about this.
|
@nicowilliams wrote:
Quite a lot of effort has been put into ensuring that jq detects invalid JSON input, so I'm hard-pressed to explain why jq allows Infinity and NaN as JSON values without so much as a command-line switch being required. If it's OK for jq to accept Infinity, then why not comments? In other words: To Infinity ... and beyond? |
'Twasn't me. It's been thus since before my time.
I'd remove it in the next version.
|
@kjaquier By the way, while jq aliases these IEEE754 values to large numbers and nulls, internally their identity is not lost, and there are builtins in 1.5 to help you deal with them (see the manual). The fact that jq accepts infinities and NaNs in JSON input is not too bothersome, and of "JSON extensions", this is a rather acceptable one I think. We should consider an option to output them too. In the meantime, this is not a bug. |
Does this mean that validation of "basic json without this float extension" is no supported use case of jq? I dont find an argument to set the used standard or extension. |
The issue is pretty simple :
Infinity
is displayed as a number andNaN
asnull
:Here I would expect the output to be similar to the input.
The text was updated successfully, but these errors were encountered: