Bug - writing data to JSON file will do nothing

I am creating a Discord Bot and I want to store some of his data to JSON file. But when I am storing it, I see nothing in my JSON file. When I do console.log() of the command to read that file I get [null, null, null, null, null]. Refresh command did nothing to the file, the problem did not “vanish”. What to do?

Can I please see how you’re saving the JSON to the file?

1 Like

It’s not safe to store data in .json files because they can get corrupted easily. There has been similar issues in the past. It looks like you need a database or persistence such as SQLite. See: https://glitch.com/help/db/

same… i was making a new language, to run side by side with nodejs and python, and it uses json, and it would not save to the json file

We cant help anyone unless you do exactly what this fellow said

x = open("JSON_STORE.json", "w+")
x.write(JSON_STR)

would not save to json

Sorry for late reply.
My project - https://glitch.com/edit/#!/quintessential-reindeer?path=commands/flashcolor.js:44:26
I was firstly saving to “commands/colors.json”, but the same problem is happening.

@MrGlebTiK,
It’s not safe to store data in .json files because they can get corrupted easily. There has been similar issues in the past. It looks like you need a database or persistence such as SQLite. See: https://glitch.com/help/db/

Also keep in mind, if you choose to update a file within your code, it will indeed update but it won’t show the new data in the glitch file tree. The data is there, but the glitch editor does not show the updates immediately.

@Promise, for it to show up, you could type Refresh in the Glitch Console!

1 Like