Convert JSON string ToJSON({ "0": What is 0 * 0 ?, "1": What is 1 * 1 ?, "2": What is 2 * 2 ?}) and store it into variable Questions.Gange
I tried with \ 's and more or less “”…
What is the expected result
I would like to be able to copy a string from outside, and have it load a lot of questions into my Scene variable array.
This way I can quickly make questions, without hardcoding them.
What is the actual result
Unable to parse JSON: SyntaxError: Unexpected end of JSON input
I never done it and i have no idea how it works
BUT
My dumbest idea would be to 1st save array to json
Open json file on some text editor to see how syntax looks
And now i could either modify it or build one myself
Wrap the whole string in double quotes. Escape all double quotes within the string that surround the values. Use square parenthesis instead or curly ones. Drop the key-value pairing to just value. Something like:
Convert JSON string ToJSON(“[\“What is 0 * 0 ?\”,\“What is 1 * 1 ?\”,\“What is 2 * 2 ?\”]”) and store it into variable Questions.Gange
I wrote a gameshow app that loads questions this way. For me, the easiest way to get everything formatted was to create the structure i wanted in gdevelop (like you did), then on a mouse click copy the formatted json to the clipboard (using the clipboard extension).
I’d then modify/tweak the questions externally (i liked usinghttps://jsonformatter.org/ cause it would indicate when i forgot a bracket and broke something). When i got it the game data the way i wanted I copy it, then do this in order to to save to a global variable, then convert that variable into the array.