I am trying to parse information from an API and output the names of each location on the JSON into a listviewer.
I previously asked about how to correctly extract the info and have managed to do so in this thread (Trying to extract a nested list from a Web API - #8 by ankitn5 ) - thanks so much for your help so far. I figured putting this in a different thread would help others in the future when they are looking for info.
My output response from the API looks like:
{
"locations":
[
{
"cost":1.2,
"address":"22 Wickham Street, Wickham 2293\n(Entrance on Charles Street)",
"max_duration":14400,
"name":"Wickham Terraces",
"gateway_id":"8642196e-83b5-4e3e-ad9b-60eb5c4f4174"
},
{
"cost":1.2,
"address":"Address 3",
"max_duration":14400,
"name":"Add 3",
"gateway_id":"8642196e-83b5-4e3e-ad9b-60eb5c4f41755555"
},
{
"cost":1.2,
"address":"Add 4",
"max_duration":14400,
"name":"Add 4",
"gateway_id":"8642196e-83b5-4e3e-ad9b-6999990eb5c4f4174"
},
{
"cost":1.4,
"address":"608 Harris Street",
"max_duration":16400,
"name":"UTS Tester",
"gateway_id":"test-2"
}
]
}
This is an example of the type of JSON rsponse I would receive, but in future it will be x number of locations (instead of the 4 in the example JSON above) provided so I need to figure out how to parse x number of items into the listviewer.
I currently have the following setup on Thunkable. This setup extract the location information into a list of objects (as seen the the solved thread above).
And this is what my app looks like when I have run the code.
I am able to output the information into a listviewer for a defined number of locations (for example 4), but cannot get it working within a for loop in order to extract the information for any number of locations.
I am hoping someone can show me how to get the for loop working, as I know this should e simple, but I’m just not able to get it.
Cheers