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 object.property or object['property']. Nesting works by adding more indexes or properties (object.property[index] etc.)

Also, remember that JS arrays are zero indexed.