JSONDecodeError:尝试json.load大文件时发生的额外数据

时间:2017-05-03 20:41:43

标签: python json python-3.x debugging

当我运行这段代码时,我拉错了这个错误,而且我不确定如何解释它。经过研究,我仍然不知道这个问题。有谁知道发生了什么。

以下是代码:

import json, sys

with open('/Users/mac/Desktop/export-2017-04-28-0235-25014395ac.json', 'r',
          encoding='utf-8') as json_data:
    d = json.load(json_data)
print(d)

另外,我想知道JSON大小是否是问题。它大约200mb。

现在出现错误:

Traceback (most recent call last):
  File "/Users/mac/Desktop/untitled.py", line 5, in <module>
    d = json.load(json_data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 342, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 15629)
[Finished in 1.5s with exit code 1]
[shell_cmd: python3 -OO -u "/Users/mac/Desktop/untitled.py"]
[dir: /Users/mac/Desktop]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

0 个答案:

没有答案