Reading data from a JSON file

Hi,

I have a JSON file -

[{"retailercat":2,"created":1737591408000,"name":"Rubis","___class":"retailers","locations":[{"created":1737590701000,"___class":"locations","location":"Coverley","ownerId":null,"updated":null,"objectId":"0449EBA2-7224-41A0-83D5-0350F43FE9A8","locid":98},{"created":1737590701000,"___class":"locations","location":"Kirtons","ownerId":null,"updated":null,"objectId":"05143668-D99B-45A6-9EB0-55BD4CB834EC","locid":107},{"created":1737590701000,"___class":"locations","location":"Barbarees Hill","ownerId":null,"updated":null,"objectId":"05A37811-CDFB-43D1-8DA2-2960E07761BD","locid":118},{"created":1737853612409,"___class":"locations","location":"Mapp Hill","ownerId":null,"updated":null,"objectId":"1643BFD8-0896-4A6C-B1E2-2F2E759E1DF9","locid":149},{"created":1737590701000,"___class":"locations","location":"Kendal Hill","ownerId":null,"updated":null,"objectId":"2C27852B-FC59-40EA-BBE3-603B6A587EAA","locid":112},{"created":1737590701000,"___class":"locations","location":"Fontabelle","ownerId":null,"updated":null,"objectId":"3B49777E-B8F8-4DAB-BA99-FE099B69A132","locid":119},{"created":1737590701000,"___class":"locations","location":"Benthams","ownerId":null,"updated":null,"objectId":"49E97CA3-6B0C-44C6-86FA-0F0F7074B314","locid":120},{"created":1737590701000,"___class":"locations","location":"Garrison","ownerId":null,"updated":null,"objectId":"6EEE6E52-3DCE-4CDD-87F8-6EF18B269221","locid":108},{"created":1737590701000,"___class":"locations","location":"Belleplaine","ownerId":null,"updated":null,"objectId":"A411EB0B-DA0E-4549-B542-4B7AA2DDF6FF","locid":121},{"created":1737590701000,"___class":"locations","location":"Wildey","ownerId":null,"updated":null,"objectId":"B9EDF44E-051A-45A1-9F7C-FF391A630C7A","locid":113}],"ownerId":null,"retailerid":8,"updated":1737655643857,"objectId":"98B4448F-1744-4B24-9EE7-09D38CD4125F"}]

I have managed to get a count on the number of locations but can’t seem to be able to iterate through the object to get the locations.

Appreciate any help.

Thanks

The tricky thing is that JSON arrays (lists) start at index 0 while Thunkable lists start at index 1. So when you see [0] in a JSON array, you have to use 1.____ in Thunkable.

When I paste your JSON response into Best JSON Viewer and JSON Beautifier Online and click on a “location” property, the path to it is:

arrayâ–ş0â–şlocationsâ–ş0â–şlocation

So in Thunkable, that would be [1].locations[1].location and you’d want to iterate through that last array [2].location, [3].location, etc. with a loop variable.

One other thing is that you are currently looping through the top array [1].locations but you want to loop through the nested array [1].location. I don’t have time to explain the fix at the moment but can probably help tomorrow if you’re still stuck.

Yes, would appreciate any further assistance you can give as I am stumped!

@tatiang, are you able to have another peek at this for me please?

Thanks
Steve

Here’s how I’d do it:

Project link: Thunkable
(See the first screen)

2 Likes

As usual, much thanks @tatiang!!

2 Likes