How to read this JSON

Hello everyone,

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

and write in the “text input”:

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


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

Could you format and repost that JSON? Use this: Best JSON Parser Online

1 Like

{
“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”
}
]
}

1 Like

MUCH better. :slight_smile:

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”?

1 Like

This block should give you the value of the second entry


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

It’s always the last one in the list

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

1 Like

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

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:

I recommend watching my API tutorial here: API JSON Tutorial (Video). It will help you understand how to parse JSON for values you want.

Edit: actually, that API isn’t returning JSON so nevermind.

1 Like

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

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

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

1 Like

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

2 Likes