Jump to page: 1 25  
Page
Thread overview
parseJSON bug
Aug 08, 2013
khurshid
Aug 08, 2013
khurshid
Aug 08, 2013
David
Aug 08, 2013
SteveGuo
Aug 08, 2013
anonymous
Aug 08, 2013
khurshid
Aug 10, 2013
Jonathan M Davis
Aug 08, 2013
Tofu Ninja
Aug 08, 2013
bearophile
Aug 08, 2013
David
Aug 08, 2013
bearophile
Aug 08, 2013
Dicebot
Aug 08, 2013
Wyatt
Aug 08, 2013
David
Aug 08, 2013
Lemonfiend
Aug 08, 2013
Dicebot
Aug 08, 2013
David
Aug 08, 2013
Adam D. Ruppe
Aug 08, 2013
David
Aug 08, 2013
Craig Dillabaugh
Aug 08, 2013
Tofu Ninja
Aug 08, 2013
David
Aug 08, 2013
Tofu Ninja
Aug 10, 2013
H. S. Teoh
Aug 10, 2013
bearophile
Aug 10, 2013
H. S. Teoh
Aug 08, 2013
Johannes Pfau
Aug 08, 2013
Adam D. Ruppe
Aug 09, 2013
Johannes Pfau
Aug 08, 2013
David
Aug 10, 2013
H. S. Teoh
Aug 10, 2013
H. S. Teoh
Aug 08, 2013
Tofu Ninja
Aug 08, 2013
Nick Sabalausky
Aug 08, 2013
Tofu Ninja
Aug 08, 2013
Wyatt
Aug 10, 2013
H. S. Teoh
Aug 08, 2013
Wyatt
Aug 08, 2013
Borislav Kosharov
Aug 10, 2013
H. S. Teoh
August 08, 2013
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
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
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
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
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
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
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
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
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

August 08, 2013
David:

> If we follow an existing implementation, we should follow JavaScript

In my opinion we should follow the formal JSON grammar.

Bye,
bearophile
« First   ‹ Prev
1 2 3 4 5