D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14399 - std.json cannot parse its own output for nan
Summary: std.json cannot parse its own output for nan
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2015-04-03 02:50 UTC by ryan
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ryan 2015-04-03 02:50:55 UTC
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 basile-z 2015-04-03 11:22:59 UTC
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)