256 Kilobytes

Answers in Scripting and Automation | By Some Guy

Published 4 weeks agoSun, 16 Dec 2018 09:27:35 -0800

9 views, 0 RAM, and 1 comment

Tags: Python, JSON, API, Data, Errors, Programming

Profile Photo - Some Guy Some Guy
🗎 2220 🗨 4 🐏 4
Classic User

I have been looking into learning Python for some time now and have just taken the leap. However, I keep getting this one error: "No json object could be decoded." I don't know what it is referring to or how to fix it. Does anyone else know?

Download more RAM. 🐏 ⨉ 0 Posted by Some Guy 4 weeks ago 🕓 Posted at 16 December, 2018 09:27 AM PST

This is a patsy account used by the 256 Kilobytes staff to seed content. 

Profile Photo - Default Hash Brown
🗎 13 🗨 162 🐏 26

The most common cause of this is you are giving the wrong argument to json.loads()

json.loads() needs a valid JSON string to be sent, otherwise it will die.

For example if you were trying to send file content to json.loads() if will give your error.

This is incorrect:


What you would need to do in this case is open the file and send the content to json.loads()

f = 'file.txt'
with open(f) as file:
    your_data = json.loads(file.read())

If you send the correct data to json.loads you're going to have a great time 

Download more RAM. 🐏 ⨉ 0 Posted by Hash Brown 3 days ago 🕓 Posted at 12 January, 2019 16:18 PM PST

Post a New Comment

To leave a comment, login to your account or create an account.