How can I access nested JSON objects that I get from an api call?

Hi my name is Dimitri and this is my first ever post on the forum. I’m trying to do the weather app challenge and I am having trouble accessing nested objects from the API respond received from openweathermap.org. Some of the data looks something like this:

“weather”:[{“id”:803,“main”:“Clouds”,“description”:“broken clouds”,“icon”:“04n”}],
“main”:{“temp”:293.25,“pressure”:1019,“humidity”:83,“temp_min”:289.82,“temp_max”:295.37},
“name”:“Cairns”,

I don’t have trouble accessing an object that is not nested so when I try json[“name”] or json.name it returns the name of the city (in this case Cairns) as expected.
The problem is when I try to access a nested object, so when I try json.weather.main or main.temp nothing is returned…
Please help I"ve been stuck on this for awhile.
Thank you!!

Note that weather is an array, not a plain object. If you want to get main, you’ll use weather[0].main.

1 Like

Thank you so much!! I didn’t even notice that haha