I have a json
file. A simplified version of it looks as following:
{
"host": "a.com",
"ip": "1.2.2.3",
"port": 8
}
{
"host": "b.com",
"ip": "2.5.0.4",
"port": 3
}
{
"host": "c.com",
"ip": "9.17.6.7",
"port": 4
}
I run this script parser.py
to parse it:
import json
from pprint import pprint
with open('myfile.json') as f:
data = json.load(f)
pprint(data)
But I'm getting this error:
Traceback (most recent call last):
File "parser.py", line 5, in <module>
data = json.load(f)
File "/usr/lib/python3.6/json/__init__.py", line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 342, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 6 column 1 (char 54)
Can you please point to me what's missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…