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

Bob Ippolito bob at redivi.com
Thu Apr 10 09:12:28 CEST 2008


On Wed, Apr 9, 2008 at 11:01 PM, John Millikin <jmillikin at gmail.com> wrote:
> On Wed, Apr 9, 2008 at 10:15 PM, Bob Ippolito <bob at redivi.com> wrote:
>  >  That sounds like a really bad idea, if there is an option to change
>  >  the behavior it shouldn't live in module state.
>  >
>  Would you rather have strictness controls as parameters? demjson
>  currently has seventeen of those. Maybe we could have loads(bytes) and
>  loads_broken(bytes, allow_trailing_comma, allow_all_whitespace,
>  allow_comments, ...) functions, one for parsing JSON, the other for
>  parsing garbage.  There's no real way to hide or remove the complexity
>  in parsing invalid data, so both warnings and parameters will cause
>  the implementation to be much larger, but at least having to call
>  warnings.filter ("ignore", JSONWarning) might serve to make some users
>  think twice.
>

Yeah just like sys.setdefaultencoding, look at how well that worked out.

simplejson has a number of options that you can pass to loads and
dumps, but if you don't explicitly use any of them it does what most
people want by default. I don't see a "loose=True" being much worse, I
probably wouldn't allow people to pick and choose exactly which
garbage to allow (except for the spec ambiguities that it already
gives you control over).

-bob


More information about the Web-SIG mailing list