"Python requests json - Why is my response not decoding properly?"
Hey folks!
So I'm trying to work with python requests json, but sometimes the response just... doesn't decode? Like, I get this weird string instead of a clean dict.
Anyone else run into this?
I usually do `response.json()` and call it a day, but sometimes it throws errors or gives me nonsense. Am I missing something? Maybe the response isn’t *actually* JSON?
Also, pro tip: check `response.headers` to see if the content-type is `application/json`. If not, that’s probably your issue.
What’s your go-to fix for this? Share your hacks!
(And yeah, I’ve tried `json.loads(response.text)` too—still weird sometimes. Ugh.)
Hey folks!
So I'm trying to work with python requests json, but sometimes the response just... doesn't decode? Like, I get this weird string instead of a clean dict.
Anyone else run into this?
I usually do `response.json()` and call it a day, but sometimes it throws errors or gives me nonsense. Am I missing something? Maybe the response isn’t *actually* JSON?
Also, pro tip: check `response.headers` to see if the content-type is `application/json`. If not, that’s probably your issue.
What’s your go-to fix for this? Share your hacks!
(And yeah, I’ve tried `json.loads(response.text)` too—still weird sometimes. Ugh.)
