Extract JSON data

Hi!
We have successfully loaded a JSON request and stored it into a variable, and it displays the data.
Our “highscore_variable” contains “{data: { results: [{name: ‘A’, score: 1}, {name: ‘B’, score: 2}]}}”.

Now, we’d like to display the top 10 from the results array (or fewer, if the array contains less entries).

Is there a way to automatically display this on a scene, and loop through the data?

I looked at this post: [Solved] How to refer to JSON data? but couldn’t figure out how to access the data/use the “Do =” syntax in Gdevelop. How do I enter that text, and where?

Is it possible to loop through the data, or populate a text field with the JSON?

Any tips for dummies are very welcome!

I’m not sure about the looping part (I’m just starting to learn myself) - but if you’ve parsed the JSON string into a variable (I’m not sure if that’s what you meant you’ve done already from your post) you can change the value of a text field by:

Selecting the action “Change the text of (object_name) set to VariableString(variablename.variablewanted)”

In my case its:

Change the text of lastname set to VariableString(returnedVars.lastName)

(Select the text field from the available objects, select modify the text under actions, choose = as the operator then enter the VariableString stuff as the value - no quotes, variable container and variable in the parenthesis)

1 Like

Thanks! We got it running now :slight_smile: