4 ms·
"NaN and Infinity" Yeah. And I learned this the hard way with the Perl module JSON::XS. It successfully encodes a Perl NaN, but its decoder will choke on tha
by mmagin 10y ago
"NaN and Infinity"
Yeah. And I learned this the hard way with the Perl module JSON::XS. It successfully encodes a Perl NaN, but its decoder will choke on that JSON. (Reported it to the maintainer who insists that is consistent with the documentation and wouldn't fix it)
- TazeTSchnitzel 10y agoSimilarly, Python's encoder violates the JSON specification by default, as it produces `Infinity`, `NaN` and `-NaN`, which other JSON parsers choke on.
- joesb 10y agoI don't get it. Why would unaware JSON parsers choke on `Infinitiy`, `NaN` or `-Nan`? JSON has no concept of schema. So if a parser sees "Inifinity", which it doesn't have any concept of, why would it do anything except treating that as string of a word "Infinity"?
- cdmckay 10y agoBecause it's not quoted like a string, it's a literal
- rurban 10y agoNobody should use JSON::XS anymore, everybody switched to Cancel::JSON::XS which does have those features, and less bugs. I just added those great testcases, and found previously unknown bugs. But the python test runner from this repo gives a few false negatives, PR coming soon. It was much easier to write it in perl.
- benibela 10y agoOh no. My parser/serializer does the same. How could that be fixed? Anything better to serialize NaN to than NaN? Or parse NaN?