Good afternoon, I read the help about converting a json file to a variable and the json syntax itself, but the program stubbornly refuses to take values from a json file. I saw an example of reading a Json string, but I don’t understand the structure of the string itself, it is complicated by “”/+ characters and it’s not clear what they are for. Even if I just added another line to that file, everything would break and display 0.
What am I doing wrong? I can’t use json structure? :
“cars”:[ “Ford”, “BMW”, “Fiat” ]
Thanks for the explanation below, it worked.
JSON is just a overall basic syntax. It isn’t a “Universal format”, so what you’ve got as an example will not work. GDevelop variables are stored in a very specific format and you will need to match that if you want to import it into a variable.
I’d recommend prebuilding a variable with the structure you’re looking for, then use the “Write a text file” filesystem action, and put your parent variable within a ToJSON Expression (if global variable, GlobalVariableToJSON(), etc) as the string of that action. Make sure you give it a path to save to using the filesystem expressions (usually the Desktop Path expression will be easiest), the filesystem delimiter, and a filename.
Then you can open that file up and review the syntax.
Run a preview and it’ll save the file