i have json file as below and tried to convert to python dictionary but getting error
{
"response": {
"dev_log": {
"data": [
{
"id": "1",
"timestamp": "2020-01-16 10:11:12",
"email": "johnd@gmail.com"
},
{
"id": "2",
"timestamp": "2020-02-27 15:33:34",
"email": "zack@gmail.com"
},
{
"id": "3",
"timestamp": "2020-02-27 15:34:07",
"email": "edy@yahoo.com"
}
],
"total_dev_log": "1423"
},
"client_log": {
"data": [
{
"customer_city": "LONDON",
"customer_login": "AAAAAAAAAAAAAA",
"customer_state": "MC",
"details": "aaaaaaaaaaa-bbbbbbbbbbbbbbb-cccccccccccccc ",
"log_number": "1",
"dept": "Sales",
"staff_id": "S123",
"staff_name": "EricY",
"timestamp": "2020-02-27 15:57:24"
},
{
"customer_city": "SINGAPORE",
"customer_login": "BBBBBBBBBBBBB",
"customer_state": "XX",
"details": "ddddddddd-eeeeeeeeeeee-ffffffffffff ",
"log_number": "1",
"dept": "Eng",
"staff_id": "S456",
"staff_name": "YongG",
"timestamp": "2020-02-27 15:57:24"
}
],
"total_hero_query": "13"
},
"response_time": "0.723494",
"transaction_id": "909122",
"transaction_status": "OK",
"transaction_time": "Fri Feb 28 15:27:51 2020"
}
}
I'm able to view as a valid json via http://jsonviewer.stack.hu. I believed its a valid json string format.
Normallay I just use code below to read json file and convert it to dict but I'm getting error.
with open('datfile.json', 'r') as f:
datDict = json.load(f)
Error
Traceback (most recent call last):
File "strg2dict.py", line 4, in <module>
json_dict = json.load(JSON)
File "/usr/lib/python2.7/json/__init__.py", line 291, in load
**kw)
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 22 column 5 (char 466)
I have check from others solution but still not able to find the solution. Please advise further. Thank you
@@@@@@@@@@@@@@@@@@@@@@@@@ Got comma "total_dev_log": "1423",
===> remove comma "total_dev_log": "1423"
RESOLVED> Thank you