Summary.
Cant parse json result because property names are in single quotes instead of double
A proper parse of course.
Caught exception Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
res=requests.get(...)
s=str(res.json())
j=json.loads(s)
python3 -m requests.help
{
"chardet": {
"version": "3.0.4"
},
"cryptography": {
"version": "2.3"
},
"idna": {
"version": "2.6"
},
"implementation": {
"name": "CPython",
"version": "3.7.3"
},
"platform": {
"release": "5.0.0-38-generic",
"system": "Linux"
},
"pyOpenSSL": {
"openssl_version": "1010100f",
"version": "19.0.0"
},
"requests": {
"version": "2.21.0"
},
"system_ssl": {
"version": "1010102f"
},
"urllib3": {
"version": "1.24.1"
},
"using_pyopenssl": true
}
This is running on up-to-date Ubuntu 19.04 and python 3.7.3
Hi @jeffreyscottgraham,
This looks like a bit of confusion about data types. You're attempting to cast a Python dictionary into a string which will use single quotes by convention.
Python dictionaries aren't directly equivalent with JSON. If you need a string representation of the data, you can either call text() on your response, or use json.dumps instead of trying to cast as a string.
I did finally figure out to use text().... i spent 4 hours literally hacking around for a solution.
May I request that an example be made part of the regular readme/documentation around the useof json(). It would have prevented all the wasted time looking for the solution.
Thanks for the ironically quick response :)
Do you have any suggestions on what you'd like to see added to the docs? We currently have example usage on the front page and a more detailed section in the quick start guide.
@jeffreyscottgraham I don't think it's up to the documentation of this project to teach you how to write Python.
Closing since the documentation appears to be in place and we didn't receive further feedback.