'stuck in python request json parse error: JSONDecodeError
When I run the python script to output a post request-response, I'm getting the following error
requests.exceptions.JSONDecodeError: [Errno Expecting ',' delimiter]
[{"pool": "https://my.pool-url.cc/pool?token=ewyhzxciOiJI", "headers": {"Connection": "close", "Content-Length": "666", "Accept-Encoding": "gzip", "Cf-Ipcountry": "US", "X-Forwarded-For": "1.1.1.1,8.8.8.8", "Cf-Ray": "4gwx2cfdqe43e2d3-QXR", "X-Forwarded-Proto": "http", "Cf-Visitor": "{"scheme":"http"}", "User-Agent": "python-requests/2.27.1", "Accept": "*/*", "Content-Type": "application/json", "Cf-Connecting-Ip": "1.1.1.1", "Cdn-Loop": "cloudflare"}, "time": "Wed Apr 6 23:17:29 2022", "regular_keys": [{"final_key": "5mw4ssn3fbg2hv1jbf6c7x8z9z0q:0q9zwv8ge7hr6t5yd4a3sf2d1f"}]}]
The error seems to be caused due to "Cf-Visitor": "{ making the json format invalid.
I want to parse the JSON output and display the final_key after the colon
for example:
0q9zwv8ge7hr6t5yd4a3sf2d1f
I tried:
r.json()[0]['regular_keys'][0]['final_key']
Solution 1:[1]
It looks like your JSON has a syntax error in it. 
You may want to escape the ends of the strings using \".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Miguel Guthridge |
