As above mentions, I’m currently trying to convert a string into a dictionary that looks like below:
"{"SOAPAction":"http://www.my-website..uk/path/To/service/v1/serviceAndLedger","ID":"1sceas2-61ae-379dd-a9cd-c813fb07u8inb", "info": {"GMT":"16/Nov/2022:12:13:46 +0000", "client":"10.177.147.71:42987", "frontend":"path/to_my_ip/12.189.66.213:8804", "request":"POST /path/service HTTP/1.1", "body":"\/path\/of\/downloaded\/file.xml", "response":"-"}}"
The issue is that the above code currently doesn’t convert into a dictionary due to some invalid JSON formatted content. Because of this, I haven’t been able to use eval, json_loads etc.
Is there any way to reformat the code so that…
A) It is in valid JSON format
B) It is able to convert the above string into a dictionary
2
Answers
Seems you have double-encoded Json(?):
Prints:
Another way, with
.replace('\"', '"')
Code:
Output: