This is what is supposed to happen: Create a new json file if it does not exist, and add an element with the keys “name” and “path”. I’m getting the following error : json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
. I’ve noticed that read_file doesn’t return anything, and I don’t know what’s wrong with it. On the print screen, I was expecting to see the content of maps.json shown in the console before “hello”.
with open("maps.json", "w+") as write_file:
with open("maps.json", "r") as read_file:
print(read_file.read(), "hello")
if read_file.read() == "":
write_file.write(json.dumps({"maps": {}}, indent=2))
write_file.write(json.loads(read_file.read()).append({"name": map_name, "path": map_destination_path}))
1