-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
inf and nan encoded as invalid JSON #28
Comments
I'm not sure if we should stringify it. It's is left out on purpose: https://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript Other libs convert it to null instead. See e.g. https://code.google.com/p/go/issues/detail?id=3480 |
There is no way to make roundtrips with inf or nan work, so as long as it produces valid JSON it is acceptable. I mention Mojo::JSON's behavior as a point of reference, converting to null like with blessed references is another option. |
I'm waiting how upstream JSON decides. |
FYI, I have let Marc know about this issue and his response was essentially "it's a bug in your code to produce invalid JSON." So JSON::XS won't be fixing it. |
Yes, that's the easiest and probable best way to handle it. Let the user check all illegal values, similar to perl, where the user has to check for all potential security problems with no strict 'refs' by himself. javascript shouldn't see inf nor nan. Let's see what makamaka thinks of it. I have no special opinion. |
Added now the testcase from makamaka/JSON-PP#10 |
No response.
|
Win32 test reports from CPAN testers are getting odd results from inf/nan encoding: http://www.cpantesters.org/cpan/report/ebf54671-6c00-1014-9247-51fd2a825c07
And this one report ended up with [-nan] somehow... I think we need two more test cases for -inf and -nan, I just tested these and they are also outputting barewords:
|
yeah. I haven't checked windows and the minus. Ok, I'll add these also. |
Fixed with 3.0111 |
Encoding a value that is represented as "inf" or "nan" results in bareword output which is not valid JSON.
Examples:
=> [inf]
=> [nan]
(In Mojo::JSON, these get encoded to the strings "inf" and "nan")
The text was updated successfully, but these errors were encountered: