[docs] [issue10976] json.loads() throws TypeError on bytes object

Antoine Pitrou report at bugs.python.org
Thu Apr 26 16:21:40 CEST 2012


Antoine Pitrou <pitrou at free.fr> added the comment:

> Things are a little more complicated. '123' is not a valid JSON
> according to RFC 4627 (the top-level element can only be an object or
> an array). This means that the autodetection algorithm will not always
> work for such non-standard data.

The autodetection algorithm needn't examine all 4 first bytes. If the 2
first bytes are non-zero, you have UTF-8 data. Otherwise, the JSON text
will be at least 4 bytes long (since it's either UTF-16 or UTF-32).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10976>
_______________________________________


More information about the docs mailing list