I'm working on a stock market analysis app using the yahoo finance api on rapidapi. I successfully pull the data from the api using requests and the result is a requests.model.response. I found that when I convert this to a json dict I get the following error (same as title):
json.decoder.JSONDecodeError: Extra data: line 1 column 5 (char 4)/raise JSONDecodeError("Extra data", s, end)
to resolve the issue I tried alternatively converting the model.response to a string then back to a dict with the following:
responset = response.text responseld = json.loads(json.dumps(responset))
I did this based off of some research I did online. No, it doesn't exactly make sense to me because this does merely seem to be a conversion of type then back to the same type. But I've thought that maybe dumps does something more than just a type conversion because I saw in another thread that this approach (that I've shown here) has been used to resolve a similar error for somebody else.
Do you have any advice? Please let me know if you need more information. Thank you.
result = json.loads(response.content.decode('utf-8'))
. Hereresponse.content
is raw-bytes data of response.result = response.json()
. My code mentioned earlier above is more low-level and may be easier debugged.