# Accessing a JSON array using a variable

**URL:** <https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935>\
**Category:** Questions about Thunkable X\
**Created:** [October 14, 2021, 3:39pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935 "2021-10-14T15:39:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![brucemortland7e6c](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@brucemortland7e6c](https://community.thunkable.com/u/brucemortland7e6c)\
**Post date:** [October 14, 2021, 3:39pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935/1 "2021-10-14T15:39:17Z")

</div>

I’m trying to access a JSON array using a variable (as in with a for loop) and it seems that you cannot access arrays in JSON with a variable. Anyone else seeing the same thing?

Thanks, Bruce

 ![ThunkableBug](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/5/45a126ceab8c57ca2029c221bd53391600eb391a.png)

[https://x.thunkable.com/copy/22af67e157d068554d20200fa5c4e691](https://x.thunkable.com/copy/22af67e157d068554d20200fa5c4e691)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [October 14, 2021, 3:48pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935/2 "2021-10-14T15:48:52Z")

</div>

Can you explain what part you want?  
You should not expect others to guess that.

---

<div class="post-metadata">

**Author:** ![brucemortland7e6c](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@brucemortland7e6c](https://community.thunkable.com/u/brucemortland7e6c)\
**Post date:** [October 14, 2021, 3:49pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935/3 "2021-10-14T15:49:32Z")

</div>

Additionally, the get property for array element 9 in the first example I do NOT know where to find it in the blocks menu. I hate to say this, but it just magically appeared when I was trying to resolve this. (and it works, too)

---

<div class="post-metadata">

**Author:** ![brucemortland7e6c](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@brucemortland7e6c](https://community.thunkable.com/u/brucemortland7e6c)\
**Post date:** [October 14, 2021, 3:52pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935/4 "2021-10-14T15:52:14Z")

</div>

Not sure I understand the questions. I CAN retrieve the part of the JSON array that I need (temp\_min)

But it appears when I try to get the element of the JSON array (in this case, 0), I can literally specify the zero either as a number or a string, but I cannot use a variable.  
Did that help?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [October 14, 2021, 3:53pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935/5 "2021-10-14T15:53:58Z")

</div>

try this

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

This way you get the element of the order required. In the example I am taking the first element in the array.

**[Edit]**  
I changed the blocks to get the first, the last and a random one

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

This is the screen

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/e/de8a6b1d7f19a4d9adf9f938f32808309df05322.png)

This is **how easy to work with arrays in Thunkable**.

---

<div class="post-metadata">

**Author:** ![brucemortland7e6c](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@brucemortland7e6c](https://community.thunkable.com/u/brucemortland7e6c)\
**Post date:** [October 14, 2021, 4:10pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935/6 "2021-10-14T16:10:10Z")

</div>

So, out of curiosity, am I accessing the wrong documentation, or is this a matter of Thunkable documentation catching up with actual code.

This was what I found/used. ([Objects - Thunkable Docs](https://docs.thunkable.com/objects))

 ![accessingObjectBlocks](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/2/021ab93f08b19ae3dbaa266de8e9a9b39118a4da.png)

---

<div class="post-metadata">

**Author:** ![brucemortland7e6c](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@brucemortland7e6c](https://community.thunkable.com/u/brucemortland7e6c)\
**Post date:** [October 14, 2021, 4:10pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935/7 "2021-10-14T16:10:45Z")

</div>

And, THANKS for the solution! It works.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [October 14, 2021, 4:26pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935/8 "2021-10-14T16:26:49Z")

</div>

This documentation was to show additional features in the `Get property` that was added later and not in the original documentation.

I would advise to see this post by @tatiang

> [@API JSON Tutorial (Video)](https://community.thunkable.com/t/api-json-tutorial-video/1140575):
>
> Using APIs in Thunkable and understanding how to parse JSON to get certain data from the API response is both a popular and a difficult aspect of using Thunkable. It’s not so much difficult because of Thunkable but because every API url format is different, every API documentation is different, every JSON response is different, etc. In this video, I spend a lot of time talking you through some best practices. It’s not a quick tutorial because if you rush through setting up an API in Thunkable, …

Very informative and to the point.

---

<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, 1:14pm UTC](https://community.thunkable.com/t/accessing-a-json-array-using-a-variable/1561935/9 "2024-11-08T13:14:49Z")

</div>


