std.json parsing real numbers.
Borislav Kosharov
bosak at gmail.com
Thu Aug 8 08:20:16 PDT 2013
On Thursday, 8 August 2013 at 10:13:51 UTC, khurshid wrote:
> On Thursday, 8 August 2013 at 10:11:07 UTC, MrSmith wrote:
>> On Thursday, 8 August 2013 at 08:04:49 UTC, khurshid wrote:
>>>
>>> I just check std.json for parsing real numbers.
>>>
>>> import std.json;
>>> import std.stdio: writeln;
>>>
>>> int main()
>>> {
>>> auto json = parseJSON("1 .24E +1");
>>> writeln(toJSON(&json));
>>> return 0;
>>> }
>>>
>>> and
>>> output: 12.4
>>>
>>>
>>> It's bug or normal ?
>>
>> Yep, because 1.24E+1 is 12.4E0
>
> I wrote not a "1.24E+1", a "1 .24E +1" with leading
> spaces.
Well what should it be if it's not 12.4? If you think it should
be 2.24 you are wrong. In JSON there are no additions or
subtractions. It is only static data. It is just a format. And
although JSON stands for JavaScriptObjectNotation it isn't JS.
Even if {"key":1.24 + 1} is valid JS it is not valid JSON.
More information about the Digitalmars-d
mailing list