Json Save System

I want a system where I can have the save files be accessed in the folders as jsons I cant figure out how to save a structure variable and then load it

i believe saving files only works for desktops, but if on a desktop, I think you’d do something like convert the structure variable to a json and save it to the save destination. (in my case “gmdata” is a global structure variable with dozens of subfolders and arrays)

then, to load it, i’d probably load the saved file into a temp variable, then convert it to the structure. This to load the data to a temp var:

then something like this to convert it back to structure:

(disclaimer: i do this all the time to send/recieve structures via mqtt but have never actually used the save to file function)

Thanks im trying to save to FileSystem::ExecutablePath() + FileSystem::PathDelimiter() + “SaveFiles/slot1.json” any idea why it wont save?

FileSystem::DocumentsPath() + FileSystem::PathDelimiter() + “slot1.json” works?

very confused if FileSystem::ExecutablePath() is broken or if im doing something wrong with folders?

1 Like

this is ultra complicated with only just two value of one object.And this is the problem all the time.The examples show the lowest,cheapest functions with that system.Never show more things the same time.

Like in my platformer checkpoint events:
-saved actual level
-saved bonus items
-saved health
-saved remaining active bonus times.

I stuck with this also.

Not true at all, you just need to use the Storage actions to save data on web and mobile. These also work on desktop so I would avoid filesystem actions unless you really need them.

I use this extension to save .json files and to be able to load them as resources:

https://wiki.gdevelop.io/gdevelop5/extensions/jsonresource-loader/

Actually question is about saving to FILE and not just saving so what Nzandydean wrote is accurate