[docs] [issue18958] Exception('No JSON object could be decoded') when parsing a valid JSON

Ezio Melotti report at bugs.python.org
Sat Oct 19 06:08:24 CEST 2013

Ezio Melotti added the comment:

Here is a proof of concept that raises this error:
>>> import json; json.load(open('input.json'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/wolf/dev/py/2.7/Lib/json/__init__.py", line 290, in load
  File "/home/wolf/dev/py/2.7/Lib/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/home/wolf/dev/py/2.7/Lib/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/wolf/dev/py/2.7/Lib/json/decoder.py", line 381, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

If the idea is OK I will add tests and implement it for the Python scanner too (and possibly tweak the error message if you have better suggestions).


Python tracker <report at bugs.python.org>

More information about the docs mailing list