[Python-3000] JSON nit

Bob Ippolito bob at redivi.com
Wed Mar 19 08:42:39 CET 2008


On Tue, Mar 18, 2008 at 8:32 PM,  <skip at pobox.com> wrote:
> Regarding putting some JSON implementation in the standard library...
>
>  I suppose anyone who uses JSON is aware of its limitations, but this was a
>  bit disconcerting:
>
>     >>> simplejson.loads(simplejson.dumps({1: 2}))
>     {u'1': 2}
>
>  Silent type conversion is a Perl thing.  I would prefer it if it raised a
>  TypeError if I tried to encode something other than a string as a dictionary
>  key.

It's also a JavaScript thing, which is why that behavior was chosen.
Yes it's silly, but no it has never caused anyone any (reported)
problems in practice.

-bob


More information about the Python-3000 mailing list