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.
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.
@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?