Bug 14399 – std.json cannot parse its own output for nan

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-04-03T02:50:55Z
Last change time
2020-03-21T03:56:42Z
Keywords
pull
Assigned to
No Owner
Creator
ryan

Comments

Comment #0 by ryan — 2015-04-03T02:50:55Z
JSONValue(["val" : float.nan]).toString yeilds `{"val":nan}`. 'nan' is not wrapped in quotes. However, if you call parseJSON on this string, it fails: "Found 'a' when expecting 'u'" (I guess its trying to parse 'null'). I would expect std.json to be able to parse the strings it outputs.
Comment #1 by b2.temp — 2015-04-03T11:22:59Z
according to this discussion, it seems that the problem appends when the value is written: "null" should be written instead of "nan": http://tools.ietf.org/html/rfc4627 " Numeric values that cannot be represented as sequences of digits (such as Infinity and NaN) are not permitted." (https://code.google.com/p/go/issues/detail?id=3480)
Comment #2 by ag0aep6g — 2015-04-03T12:14:26Z