On Wed, Apr 9, 2008 at 5:48 PM, Alan Kennedy <[EMAIL PROTECTED]> wrote: > [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?
simplejson would give you an error and tell you exactly where the problem was, but there isn't currently a non-strict mode and honestly nobody has asked for it. -bob _______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com