I am trying to parse the following json text in python but I am getting error,
Although I am able to parse this json text using a Json Viewer . So I guess my json text is correct , Can someone please help me what is wrong here ?
import json as j
data = '{"c":[{"xy":{"xstart":0,"xend":5,"ystart":1,"yend":5},"names":["D","T","O","H","L","C",],"co":["rgb(0,0,128)"]}],"Values":{"D":["11/30/2012"],"T":["09:44:00"],"O":["5848.40"],"H":["5848.40"],"L":["5847.45"],"C":["5848.40"]}}'
json_data = j.loads(data)
#print json_data["c"][0]
Traceback (most recent call last):
File "C:json\jsonexample.py", line 4, in <module>
json_data = j.loads(data)
File "C:\Python27\lib\json\__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
It looks like it is a problem with your actual string. This line:
Has an extra comma after the
"C". Try removing that and see if it works as expected.