# Reading data from a JSON file

**URL:** <https://community.thunkable.com/t/reading-data-from-a-json-file/3525282>\
**Category:** Questions about Thunkable X\
**Created:** [January 31, 2025, 2:33am UTC](https://community.thunkable.com/t/reading-data-from-a-json-file/3525282 "2025-01-31T02:33:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve\_synopsis](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@steve\_synopsis](https://community.thunkable.com/u/steve_synopsis)\
**Post date:** [January 31, 2025, 2:33am UTC](https://community.thunkable.com/t/reading-data-from-a-json-file/3525282/1 "2025-01-31T02:33:39Z")

</div>

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"}]`

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/5/15afc302875aeec371561662682e9f5149c87ed1.png)

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 31, 2025, 3:20pm UTC](https://community.thunkable.com/t/reading-data-from-a-json-file/3525282/2 "2025-01-31T15:20:11Z")

</div>

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](https://codebeautify.org/jsonviewer) 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.

---

<div class="post-metadata">

**Author:** ![steve\_synopsis](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@steve\_synopsis](https://community.thunkable.com/u/steve_synopsis)\
**Post date:** [January 31, 2025, 9:07pm UTC](https://community.thunkable.com/t/reading-data-from-a-json-file/3525282/3 "2025-01-31T21:07:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![steve\_synopsis](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@steve\_synopsis](https://community.thunkable.com/u/steve_synopsis)\
**Post date:** [February 3, 2025, 11:18am UTC](https://community.thunkable.com/t/reading-data-from-a-json-file/3525282/4 "2025-02-03T11:18:01Z")

</div>

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

Thanks  
Steve

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [February 4, 2025, 7:40am UTC](https://community.thunkable.com/t/reading-data-from-a-json-file/3525282/5 "2025-02-04T07:40:13Z")

</div>

Here’s how I’d do it:

Project link: [Thunkable](https://x.thunkable.com/copy/ca29a11620041813465ffe6546502c46)  
(See the first screen)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/8/f8ad84c6ea5965badecf94150eeeddd404ac2b2c.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0fc102126251ae3dbf57a6a89127c91ecc979bf7.png)

---

<div class="post-metadata">

**Author:** ![steve\_synopsis](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@steve\_synopsis](https://community.thunkable.com/u/steve_synopsis)\
**Post date:** [February 5, 2025, 1:10am UTC](https://community.thunkable.com/t/reading-data-from-a-json-file/3525282/6 "2025-02-05T01:10:25Z")

</div>

As usual, much thanks @tatiang!!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [May 6, 2025, 1:11am UTC](https://community.thunkable.com/t/reading-data-from-a-json-file/3525282/7 "2025-05-06T01:11:09Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
