I have a json file that looks like this exactly:
{'data':[-99,19,1212,121,2131,323321,123]}
saved as list.json
and I have a python script that needs the list [-99,19,1212,121,2131,323321,123]
import json
with open ("list.json", "r") as myfile:
data=myfile.read().replace('\n', '')
spots1 = json.loads(data) #<-- Error
spots = spots1['data']
Error:
File "pythonscript.py", line 479, in <module>
spots1 = json.loads(data)
File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
I can't figure out what is wrong with my formatting. Any help would be greatly appreciated!