[Solved] json variable return text 0

at the beginning of scene (as a condtion) i am sending a GET request for a json file and converting it to a variable. it all work fine so when debugging i can see the data is in the varaible instances, but when i try put some of the data as text on the scene the text becomes 0.

help please

thanks
Gil

There are several types of variables. If you want to display number variables in a text object, you need to convert them to text. e.g. ToString(Variable(score))

i tried using toString(), but it still stays 0. i think maybe the variable is instantiate with 0 because the request takes time. can u help with that matter?

{
“data”:“value”,
“seconddata”:[
“src”:“scontrino1.jpg”,
“hide”:“true”,
“open”:“true”,
]
}

this json save in x variable
change variable data ------> VariableString(x[data]) === “value”
chnge data variable open —> VariableString(x[“secondata”][“open”]) ==== “value”

example to acces in event sheet or in javascript
javascript offer some advantages for exambe you need read the lenght of object

in javascript use x._str and you take the string value ecc ecc




You should learn to make the difference between a variable and a variable structure.
An variable can have a children, this variable is called structure variable.
If a variable have no children you can call this one a variable.

Wiki about Dynamic access to the children

runtimeScene.getVariables().get("root").getChild("Child").getAsString()

return:
"myValue"

getChild(number) cannot work, you need always pass a value as text.

If you use _children or _str this can be broken one day, use the good pratice with .getChild(“mychild”) and .getAsString()

I know but I have an array of children and in my case I want to choose a random child and take his own property. Array has a numbering from 0 to x so I pass them as a parameter to a object that contains a number
you’re right better to use .getAsString () than ._str

I don’t have the data saved on a variable structure but on a json