# Working with a JSON API Array

**URL:** https://community.thunkable.com/t/working-with-a-json-api-array/965893
**Category:** Questions about Thunkable X
**Created:** [November 10, 2020, 11:41pm UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893 "2020-11-10T23:41:59Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![matt7](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/matt7/32/88486_2.png) [@matt7](https://community.thunkable.com/u/matt7)
#### Post date: [November 10, 2020, 11:41pm UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893/1 "2020-11-10T23:41:59Z")

</div>

Hi

I have tried to look at past threads on this but I just can’t read my head round how I am supposed to handle an array of objects.

This is what I have so far:

 ![Screenshot 2020-11-10 at 23.41.40](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/9/792604b5be1a955c5391b46e2f1d87e07b2671ff.png)

I can get eg. record 1 by setting but I don’t understand how to get all of them, I know once I do this to then put them in a list.

Tried searching for a tutorial on this but couldn’t find one.

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: [November 10, 2020, 11:50pm UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893/2 "2020-11-10T23:50:54Z")

</div>

You should be able to loop from 1 to the length of the JSON array (it looks like there are 10 entries but I’m not sure how to get this dynamically) and use the loop index variable (e.g. **i** ) as the “1” in your get property field. As you get the value, add it as the last item in a list instead of setting app apiResponse to the value.

---

<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: [November 11, 2020, 1:53am UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893/3 "2020-11-11T01:53:37Z")

</div>

I went to [https://wowfreebies.co.uk/wp-json/wp/v2/offer](https://wowfreebies.co.uk/wp-json/wp/v2/offer) and copied the JSON into a text string assigned to a variable. But I’m having a hard time parsing it because I don’t know the categories values. What’s an example of a ?categories= value that works with this API?

**Edit:** oh, 9 works.

Hmm. I’m used to JSON objects but this is presenting an array (starting with a bracket [ ). I had thought a list block might work with it but I haven’t had any luck.

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [November 11, 2020, 1:56am UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893/4 "2020-11-11T01:56:38Z")

</div>

I love me some JSON!

Here is my approach:  
Set APP apiResponse to Get Object From JSON -\> Response  
For each i in APP apiResponse  
FROM idTest SET text TO Generate JSON from Object -\> i

That should iterate through the list displaying the JSON for each item. You can progressively parse the results. You might also check out [JSON Explorer/Browser](http://community.thunkable.com/t/json-explorer-browser/957664) see what the results look like.

Feel free to DM me with specific questions. I use JSON almost exclusively for data storage, so I’ve got tons of tips and tricks.

---

<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: [November 11, 2020, 2:04am UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893/5 "2020-11-11T02:04:13Z")

</div>

Here’s an example that works with a set # of array items (5):

 ![Screen Shot 2020-11-10 at 6.03.00 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/7/9789db274649bbbd7446f7ad9dbae19a3977ffee.png)

 ![Screen Shot 2020-11-10 at 6.03.54 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/1/a1b7cd9b62c7eec6f3d6ca86eb75b6293584f826.png)

---

<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: [November 11, 2020, 2:11am UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893/6 "2020-11-11T02:11:36Z")

</div>

> [@drted](#):
>
> Set APP apiResponse to Get Object From JSON → Response  
> For each i in APP apiResponse

I was thinking the same thing. And that **does** work. I’ll post a dynamic version of the blocks in a minute.

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [November 11, 2020, 2:14am UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893/7 "2020-11-11T02:14:46Z")

</div>

[tatiang](http://community.thunkable.com/u/tatiang),  
find that the For Each is super handy for JSON arrays vs. For i = X to Y, they save the step of figuring out how long the array is.

---

<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: [November 11, 2020, 2:23am UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893/8 "2020-11-11T02:23:58Z")

</div>

@drted I love toying with JSON too, but I find it super frustrating. A good kind of frustrating – usually – but still frustrating.

Alright, this works:

**Edit:** just realizing that the _set app JSON object_ block should be inside the else section of the if/do block. I was rushing a bit when I made that.

 ![Screen Shot 2020-11-10 at 6.33.43 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/9/09ab7fb3afc2b9e64e9222fcdf5e6dc99805d38b.png)

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 12:21pm UTC](https://community.thunkable.com/t/working-with-a-json-api-array/965893/9 "2024-11-08T12:21:44Z")

</div>


