May-08-2019, 12:32 PM
Hi,
I am trying to decode the string as dict.
I tried using json.dumps as seen below
I am trying to decode the string as dict.
>>> json_string '{"ip": "13.1.6.0","data": {"tls": {"status": "io-timeout","protocol": "tls","timestamp": "2019-05-08T16:02:43+05:30","e rror": "EOF"}}}{"ip": "13.1.6.0","data": {"tls": {"status": "unknown-error","protocol": "tls","timestamp": "2019-05-08T16:0 2:43+05:30","error": "tls: oversized record received with length 20527"}}}{"ip": "13.1.6.1","data": {"tls": {"status": "io-timeout","protocol": "tls","timestamp": "2019-05-08T16:02:43+05:30","error": "read tcp 13.1.6.0:60812-\\u003e13.1.6.0:443: read: connection reset by peer"}}}'How can i decode the above string such that i can access like json_string["ip"], json_string["ip"]["tls"]
I tried using json.dumps as seen below
json_data = json.dumps(json_string) >>> json_data["ip"] Traceback (most recent call last): File "<input>", line 1, in <module> json_data["ip"] TypeError: string indices must be integers, not strplease help.
