Thread overview | |||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 08, 2013 parseJSON bug | ||||
---|---|---|---|---|
| ||||
std.json parseJSON has a bug, // leading whitespaces auto json = parseJSON("1 .000"); -- should throws, but it's success parsed as `1.000` . Khurshid... |
August 08, 2013 Re: parseJSON bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to khurshid | On Thursday, 8 August 2013 at 12:08:00 UTC, khurshid wrote:
>
> std.json parseJSON has a bug,
>
> // leading whitespaces
> auto json = parseJSON("1 .000");
>
> -- should throws, but it's success parsed as `1.000` .
>
>
> Khurshid...
Or more...
auto json = parseJSON(`{ "one": 1 .24E +1 }`);//should throws.
writeln(toJSON(&json)); // printed `{"one":12.4}`
|
August 08, 2013 Re: parseJSON bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to khurshid | Am 08.08.2013 14:15, schrieb khurshid:
> On Thursday, 8 August 2013 at 12:08:00 UTC, khurshid wrote:
>>
>> std.json parseJSON has a bug,
>>
>> // leading whitespaces
>> auto json = parseJSON("1 .000");
>>
>> -- should throws, but it's success parsed as `1.000` .
>>
>>
>> Khurshid...
>
> Or more...
>
> auto json = parseJSON(`{ "one": 1 .24E +1
> }`);//should throws.
> writeln(toJSON(&json)); // printed `{"one":12.4}`
Why is this a bug? JSON ignores whitespaces outside strings.
|
August 08, 2013 Re: parseJSON bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to khurshid | On Thursday, 8 August 2013 at 12:08:00 UTC, khurshid wrote: > > std.json parseJSON has a bug, > > // leading whitespaces > auto json = parseJSON("1 .000"); > > -- should throws, but it's success parsed as `1.000` . > > > Khurshid... I think bug reports should be here http://forum.dlang.org/group/digitalmars.D.bugs |
August 08, 2013 Re: parseJSON bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to khurshid | On Thursday, 8 August 2013 at 12:08:00 UTC, khurshid wrote:
>
> std.json parseJSON has a bug,
>
> // leading whitespaces
> auto json = parseJSON("1 .000");
>
> -- should throws, but it's success parsed as `1.000` .
>
>
> Khurshid...
I don't think this is a bug, the json spec seems to indicate that this is valid.
|
August 08, 2013 Re: parseJSON bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to SteveGuo | On Thursday, 8 August 2013 at 12:38:39 UTC, SteveGuo wrote: > I think bug reports should be here http://forum.dlang.org/group/digitalmars.D.bugs Actually, that only shows the activity on the bug tracker. New issues should be reported here: http://d.puremagic.com/issues |
August 08, 2013 Re: parseJSON bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tofu Ninja | Tofu Ninja: > I don't think this is a bug, the json spec seems to indicate that this is valid. The JSON decode of the Python2.6.6 standard library seems to refuse it: >>> import json >>> json.loads("1.000") 1.0 >>> json.loads("1 .000") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "...\Python26\lib\json\__init__.py", line 307, in loads return _default_decoder.decode(s) File "...\Python26\lib\json\decoder.py", line 322, in decode raise ValueError(errmsg("Extra data", s, end, len(s))) ValueError: Extra data: line 1 column 35 - line 1 column 39 (char 35 - 39) Bye, bearophile |
August 08, 2013 Re: parseJSON bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to SteveGuo | On Thursday, 8 August 2013 at 12:38:39 UTC, SteveGuo wrote: > On Thursday, 8 August 2013 at 12:08:00 UTC, khurshid wrote: >> >> std.json parseJSON has a bug, >> >> // leading whitespaces >> auto json = parseJSON("1 .000"); >> >> -- should throws, but it's success parsed as `1.000` . >> >> >> Khurshid... > > I think bug reports should be here http://forum.dlang.org/group/digitalmars.D.bugs I reported. http://d.puremagic.com/issues/show_bug.cgi?id=10776 |
August 08, 2013 Re: parseJSON bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | Am 08.08.2013 14:54, schrieb bearophile:
> Tofu Ninja:
>
>> I don't think this is a bug, the json spec seems to indicate that this is valid.
>
>
> The JSON decode of the Python2.6.6 standard library seems to refuse it:
>
>>>> import json
>>>> json.loads("1.000")
> 1.0
>>>> json.loads("1 .000")
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "...\Python26\lib\json\__init__.py", line 307, in loads
> return _default_decoder.decode(s)
> File "...\Python26\lib\json\decoder.py", line 322, in decode
> raise ValueError(errmsg("Extra data", s, end, len(s)))
> ValueError: Extra data: line 1 column 35 - line 1 column 39 (char 35 - 39)
>
>
> Bye,
> bearophile
JSON.parse("1 .000")
SyntaxError: Unexpected token .
If we follow an existing implementation, we should follow JavaScript
|
Copyright © 1999-2021 by the D Language Foundation