[Web-SIG] Time a for JSON parser in the standard library?

Alan Kennedy pywebsig at xhaus.com
Thu Apr 10 02:48:11 CEST 2008


[Alan]
>> [hand written JSON containing a] hard-to-spot dangling comma, from all the
>>  copying and pasting. That broke his javascript library; he solved the
>>  problem by passing it through a PHP JSON codec on his local Apache. It
>>  worked, i.e. his problem disappeared, but he didn't know why (the PHP
>>  lib had eliminated the dangling comma). Which all goes to confirm,
>>  IMHO, that you should be liberal in what you consume and strict in
>>  what you produce.

[John]
>  Sounds like a case *for* strict parsing, in my opinion. PHP's loose
>  parsing made it difficult to figure out why the JSON was invalid. If
>  trailing comma handling is to try to work around copy-paste errors, -1
>  from me.

No, the PHP lib did exactly what it should, IMHO. The PHP lib was
liberal in what it consumed (a dangling comma), and strict in what it
produced (no dangling comma).

It accepted my broken document with a dangling-comma, and emitted a
strictly conformant document with the offending comma removed, which
enabled my co-worker to proceed with his job.

+1 from me.

Other opinions?

Alan.


More information about the Web-SIG mailing list