Cant parse json data

Im trying to read data from json file. I can successfully read data from json. But when im trying to parse its return me 0

Here is screenshot of eventsheet

Here is my json file
file

[{
“initialisation” : {
“level” : “1”,
“life” : “100”,
“time” : “60”
},
“monsters” : {
“monster0” : “100”,
“monster1” : “90”,
“monster2” : “200”,
“monster3” : “60”
},
“friendsname” : {
“friend0” : “Mark”,
“friend1” : “Justin”,
“friend2” : “Robert”,
“friend3” : “Brad”
}
}]

Here is my gdevelop save file
Gdevelop save file

Im trying to figure whats wrong for hours. Read many tutorials and tried many things. But nothing worked. Anyone can look and help me?

Hey VishwaR,

I have played around with JSON in my previous project and I am doing it again now so I thought I’'d mention that once you parse the JSON string to scene/global/object variable it “groups” up like the below.


So this means you will need to include what group your variable is in, for example if I wanted to get the options-3 text, I’d have to use variable_name.1.option-3 as it’s in group 1.

If you know what number each group will be, it should be fairly simple to update your variables. Otherwise you may have to look into creating a key/value system to keep track of what group has what data.

EDIT: Looks like you do know about the group, however your Parse JSON string should be VariableString(myjsonfilevariable) as that is where you stored the raw string, also JSON file is not formatted correctly. Remove your ” from the keys/values and use "

I have re-uploaded the project (https://multifilemirror.com/zmnmv7hhfr5u/Vish Fixedr.zip.html) fixed for you. Have a look at the json formatting and I’d suggest using a place like https://jsonformatter.curiousconcept.com to keep it clean and detect any bad formatting.

1 Like

@Eiklahc thanks about your opinion. I know about what u saying. I need to read data from group 0 in my json and i already did as you say. But no result :(:disappointed_relieved:

You were too quick! :D, Have a look at my edited reply. It’s fixed.

1 Like

@Eiklahc thank you very much. You saved me :grin: so error on my json file. I never thought about that. Thanks again my friend