How do i edit JSON file using python?

So i have a python bot(a custom whitelist system) and it needs to use JSON file to store stuff.
It does store the data BUT every time i edit the code it just warps back. + that JSON file doesnt update in editor as well.
Edit: I fixed it, now the project is stuck at Starting and i cant retrieve whitelist.json file to use.

Hi there! :waving_hand: Welcome to the community!

Can you send us the link to your program? :link:

Thanks!

The editor doesn’t automatically pick up edits that happen outside of the editor, you’ll need to run the refresh command in the editor terminal (button at the bottom) if you want to see updated files.

As for how it’s done in Python, you generally use the json module and its “.loads” (for “loads (as) s(tring)” and “.dumps” (for “dump (as) s(tring)”) functions.

If you broke your project in the sense that the preview doesn’t work, but the editor works fine, open your project log (also a button at the bottom) and have a look at what errors/warnings that shows you.

If you broke the project so hard you can’t even load the editor, please write into support@glitch.com with all the details necessary for folks to see how what happened there (because normal bad code should absolutely prevent a preview from happening, but should not prevent the editor from loading up your project so you can fix it).

1 Like