How do I solve this error JSONDecodeError("Expecting value", s, err.value) from None

Hi, I was making a GUI which allows user to Type a website and generate a password and then store the website and the respective password in a json file names “data.json” . Now I am enrolled in a course called “100 days of code” by Angela Yu. I have encountered an error and I have got no idea how to solve it even after looking online.

Here is a link to my code which gives error —> 236A-CF/ at 1d6ca62fd7eb4e653a1718d381675042505b3ced · hp68kgp/236A-CF · GitHub

The screenshot below shows the error.

Would be very helpful if someone explains me why this is arising.

@hp68 could you send the contents of the file data.json. I have a feeling that it’s empty. If it is, write {} in it.

1 Like

Hi there Cactus! Thank you so much for your solution. I spent almost an hour behind this but couldn’t figure this out. Could you please also explain why I need to add the {} in my json file and how it solves this issue because in my friend’s device, his json file was completely empty but it worked without giving an error.

Thanks a ton once again!

@hp68 no problem! The issue is, when you use the load() function, it tries to parse the json file. But if that file is empty, then there is no valid json in the file so it errors. I’m not sure why it would work on your friends device. Maybe they write to the file before trying to read it?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.