How to access JSON items?

If I understand correctly, list in this code is an array that consists of objects. I want to access temp in the main object and thought main.temp would do the trick, but I get an error message stating it’s undefined. Alternatively I’ve tried list[1].main.temp. What is the correct way to access JSON data?

Have you tried list[0].main.temp ?

Assign the JSON string to a variable, parse it with JSON.parse(), and then you can use it like any other JavaScript data. If it’s an index of an array, use array[index]; if it’s a property of an object, use or object['property']. Nesting works by adding more indexes or properties ([index] etc.)

Also, remember that JS arrays are zero indexed.

List is an array. It appears to have at least one object. If you forgot how to get access an element, you really should review the challenges in Basic Javascript on arrays. Here is one which can help you on the question you have.