I am trying to load a json file in python. My json file looks like this:
{'awesomeness': 2.5, 'party': 'Republican', 'Age': 50, 'State': 'California', 'Ideology': 0.5,
'time': {'day': 20, 'mon': 2, 'sec': 3}, 'overall': 9.5, 'review': 'Best Senator ever\tPretty balanced
view.\tNot sure if he can get reelected'}
{'awesomeness': 0.5, 'party': 'Republican', 'Age': 70, 'State': 'New York', 'Ideology': 0.8,
'time': {'day': 25, 'mon': 8, 'sec': 31}, 'overall': 5.5, 'review': 'NA'}
This is my code.
with open("senator.json") as json_file:
data = json.load(json_file)
But I got following error,
File "<stdin>", line 1, in <module>
File "<string>", line 2, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 290, in load
**kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 381, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 1 column 2 (char 1)
Why do I get this error and how can I load this file? Thanks for any help!