# How to read this JSON

**URL:** <https://community.thunkable.com/t/how-to-read-this-json/1307800>\
**Category:** Questions about Thunkable X\
**Created:** [May 26, 2021, 1:01am UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800 "2021-05-26T01:01:52Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![francorodrigognrczl](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@francorodrigognrczl](https://community.thunkable.com/u/francorodrigognrczl)\
**Post date:** [May 26, 2021, 1:01am UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/1 "2021-05-26T01:01:53Z")

</div>

Hello everyone,

I want to read this value when I click on the button::

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

and write in the “text input”:

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

But I don’t know how to do it:  
I tried to put the logic this way:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/8/78cdbb8d6fa487b1da59b72bd4b127eb0d23f42e.png)  
I don’t know how to it the value in the “text input”.  
This is the API: [https://api.thingspeak.com/channels/1306356/fields/1.json?results=2](https://api.thingspeak.com/channels/1306356/fields/1.json?results=2)

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [May 26, 2021, 1:34am UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/2 "2021-05-26T01:34:26Z")

</div>

Could you format and repost that JSON? Use this: [Best JSON Parser Online](https://jsonformatter.org/json-parser)

---

<div class="post-metadata">

**Author:** ![francorodrigognrczl](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@francorodrigognrczl](https://community.thunkable.com/u/francorodrigognrczl)\
**Post date:** [May 26, 2021, 2:15pm UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/3 "2021-05-26T14:15:22Z")

</div>

{  
“channel”: {  
“id”: 1306356,  
“name”: “Pintinho”,  
“latitude”: “0.0”,  
“longitude”: “0.0”,  
“field1”: “LUZ”,  
“field2”: “CORTINA”,  
“field7”: “ArrumarData”,  
“created\_at”: “2021-02-16T05:02:31Z”,  
“updated\_at”: “2021-05-25T23:37:26Z”,  
“last\_entry\_id”: 763  
},  
“feeds”: [  
{  
“created\_at”: “2021-05-26T02:00:30Z”,  
“entry\_id”: 762,  
“field1”: “0”  
},  
{  
“created\_at”: “2021-05-26T03:09:53Z”,  
“entry\_id”: 763,  
“field1”: “1”  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [May 26, 2021, 2:24pm UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/4 "2021-05-26T14:24:16Z")

</div>

MUCH better. 🙂

So, your top level properties are “channel” and “feeds”, and “feeds” is an array, with two entries. How do you know which ‘field1’ value you want? Is it always the last one in the list, or is it the one that’s “entry\_id” matches “last\_entry\_id”?

---

<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:** [May 26, 2021, 2:29pm UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/5 "2021-05-26T14:29:49Z")

</div>

This block should give you the value of the second entry

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/1/91cd58be678e77d51ac3137a3777055a0a25d8f9.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/a/9a3a0235b12e222ffaa4a03e0350a4158dbc8fad.png)

As @catsarisky explained, you need to add the criteria to decide which entry in the list.

---

<div class="post-metadata">

**Author:** ![francorodrigognrczl](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@francorodrigognrczl](https://community.thunkable.com/u/francorodrigognrczl)\
**Post date:** [May 26, 2021, 6:00pm UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/6 "2021-05-26T18:00:56Z")

</div>

> [@catsarisky](#):
>
> Is it always the last one in the list

It’s always the last one in the list

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [May 26, 2021, 7:06pm UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/7 "2021-05-26T19:06:51Z")

</div>

Great. So use muneers blocks but change 2 to “last”

---

<div class="post-metadata">

**Author:** ![francorodrigognrczl](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@francorodrigognrczl](https://community.thunkable.com/u/francorodrigognrczl)\
**Post date:** [May 27, 2021, 3:34am UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/8 "2021-05-27T03:34:55Z")

</div>

So, I would like to take this value from this address:

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

and compare as follows:  
if the result is equal to 0, write OFF in TextInput1  
if the result is equal to 1, write ON in TextInput1  
I tried this way:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/d/fdbdb48aa85407fb7f3ded3068631ab881690ce1.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:** [May 27, 2021, 3:46am UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/9 "2021-05-27T03:46:26Z")

</div>

I recommend watching my API tutorial here: [API JSON Tutorial (Video)](https://community.thunkable.com/t/api-json-tutorial-video/1140575). It will help you understand how to parse JSON for values you want.

**Edit:** actually, [that API](http://api.thingspeak.com/channels/1306356/fields/1/last.html) isn’t returning JSON so nevermind.

---

<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:** [May 27, 2021, 3:51am UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/10 "2021-05-27T03:51:52Z")

</div>

Replace the second text/url block with the green response block. You may want to change the “Hint” drop-down menu to “Text”.

---

<div class="post-metadata">

**Author:** ![francorodrigognrczl](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@francorodrigognrczl](https://community.thunkable.com/u/francorodrigognrczl)\
**Post date:** [May 27, 2021, 4:21am UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/11 "2021-05-27T04:21:05Z")

</div>

This API can return a json, I need just to change the lasts letters, this way:  
[http://api.thingspeak.com/channels/1306356/fields/1/last.json](http://api.thingspeak.com/channels/1306356/fields/1/last.json)

---

<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:** [May 27, 2021, 4:38am UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/12 "2021-05-27T04:38:00Z")

</div>

Okay, it depends what you prefer but it seems pretty simple to just replace the url with the green block as I suggested.

---

<div class="post-metadata">

**Author:** ![francorodrigognrczl](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@francorodrigognrczl](https://community.thunkable.com/u/francorodrigognrczl)\
**Post date:** [May 27, 2021, 5:10am UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/13 "2021-05-27T05:10:31Z")

</div>

Thanks dude. Your video help me a lot, now its working.  
I wanted to do this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/8/a820e5972f776914b86c8def3b355a8e4712e39f.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, 1:22pm UTC](https://community.thunkable.com/t/how-to-read-this-json/1307800/14 "2024-11-08T13:22:22Z")

</div>


