[issue21451] Improve error messages for malformed JSON

R. David Murray report at bugs.python.org
Wed May 7 19:55:44 CEST 2014


R. David Murray added the comment:

Python 3.4.0+ (3.4:d994d75cce95, May  6 2014, 21:37:02) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> json.loads('''[
...           "boys": 10,
...           "girls": 20,
...          ]''')
Traceback (most recent call last):
   ...
ValueError: Expecting ',' delimiter: line 2 column 17 (char 18)
>>> json.loads("['python', 'perl', 'ruby']")
Traceback (most recent call last):
   ...
ValueError: Expecting value: line 1 column 2 (char 1)
>>> json.loads("[[10, 20], [30, 40]]]")
Traceback (most recent call last):
   ...
ValueError: Extra data: line 1 column 21 - line 1 column 22 (char 20 - 21)

See issue 16009 for when this was added. Can you improve these? (The first one looks odd...)  If so, you could reopen this.

----------
nosy: +r.david.murray
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Json error messages could provide more information about the error
versions:  -Python 2.7, Python 3.4

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


More information about the Python-bugs-list mailing list