-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expecting property name enclosed in double quotes #5412
Comments
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 |
I did finally figure out to use text().... i spent 4 hours literally hacking around for a solution. |
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. |
@sigmavirus24 examples actually speed up the development process. "Tell me and I forget, teach me and I learn". |
@osamaramihafez we have examples but no one has explained how to improve them or what was confusing. OP here seemed to not find an example that's in the docs but didn't tell us what they looked for or how to improve that discoverability. Without details beyond "I did this wrong and your docs are bad" we can't action very much. That said, every library's documentation can not be responsible for making sure you've learned the language sufficiently well by teaching you how to write code in that language. There will always be superior resources for that elsewhere and it's not worth my time to half-ass that. Finally, more is not always better of it makes crucial examples harder to find. No piece of documentation written entirely by volunteers on limited time can satisfy everyone, but it can satisfy 95% and that's better than perfect. |
was this thread supposed to help me convert You're suggesting to use json.dumps, but if I could do that I wouldn't need to convert it INTO a json. That's how I'm getting the strings and I don't have control over how they get encoded. |
@EightRice if you can't import something from the standard library I don't know how to help you generate valid JSON or handle invalid JSON. Also, if you're getting garbage over the wire, it's not this library's responsibility to magically understand the intent you have for using garbage. You'll need to discern how to parse that string correctly and (hopefully) safely and understand those trade-offs because, as I think you realize, you're not being sent JSON. |
Summary.
Cant parse json result because property names are in single quotes instead of double
Expected Result
A proper parse of course.
Actual Result
Caught exception Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
Reproduction Steps
res=requests.get(...)
s=str(res.json())
j=json.loads(s)
System Information
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
The text was updated successfully, but these errors were encountered: