How do you get a nested json object from an array

Hi all,

I’ve seen various ways to extract json data using Get Object and I can get a single Object’s field values, however, I don’t seem to be able to access a nested object’s value or run any debug, I just get undefined.

Here is the JSON where I simply want to extract the second ‘field4’ value which seems to be inside a 3rd nested JSON object in the array.

This JSON Data is actually only 1 Result set not a set of 2 result sets.

{“channel”:{“id”:860888,“name”:“Salt Level Checker”,“description”:“Distance ToF - Salt Level Checker in mm”,“latitude”:“0.0”,“longitude”:“0.0”,“field1”:“Distance”,“field2”:“Charge”,“field3”:“Voltage”,“field4”:“Battery”,“created_at”:“2019-09-09T19:02:32Z”,“updated_at”:“2019-11-04T22:01:26Z”,“last_entry_id”:314},“feeds”:[{“created_at”:“2020-05-03T12:20:48Z”,“entry_id”:314,“field4”:“929”}]}

What I want to get is the last ‘field4’ value which is ‘929’ but I cannot seem to do it with GetObject.
I also can’t tell whether I am retrieving the second created_at entry or the first one.

This is my stab at it that is giving me undefined on the last Get Object for the set ADCValue which I want to set to the field4 value 929:-

I would be most grateful to anyone who can help me here

I’ll take a better stab at this later. But a question is where does the Json come from? Are you able to read any of the values provided?

1 Like

Hi Jared, yes I am able to GET a few values.

This is the actual URL of the JSON: https://api.thingspeak.com/channels/860888/fields/4.json?results=1

I’m pulling back ‘Salt level checker’ for the first set (JSONName) GetObject
I am pulling back ‘battery’ for the second (JSONFieldName) GetObject
I am pulling ‘2019-09-09T19:02:32Z’ from ‘created_at’ in the 3rd (JSONTimeDate) Get Object
I cannot pull field4’s value 929 at the end of the string (in a nested object)

Thanks Oliver

Something to look at would be my example app for dealing with just this thing. It’s called nestDLstR

Find it here
http://jaredgibb.xyz/thunkable/sample-apps/

Thanks Jared, I’ll take a look and post back if I have a question or success!
Oliver

Hi Jared,
I cannot find nestDLstR but did find NestdList - however that one doesn’t have any JSON and getObjects in it. Sorry, am I missing something? I tried searching for nestDLstR too, but no joy.
Oliver

What this JSON appears to have is 2 x Objects and 1x List, but the list is in the second Object so I cannot seem to reference that. I would love to understand how to reference different objects and lists within objects.

If that doesn’t work, I need to fix it :rofl:

I’ve named it a couple ways. Sorry for the confusion.

help help anyone?

this thread is old, but i ran into the same trouble of trying to read from thingspeak. This was my solution.

the field4 you’re looking for isn’t in a 3rd nested JSON, it’s just in the feeds array > field4.

This is the URL I used to read from my field6:
https://thingspeak.com/channels/######/fields/6.json?results=1