I've written some code where I'm attempting to display certain values in HTML. Specifically, I am looking to extract the values from the "current" object:
("dt":1643884851, "temp":8.11, "description":"few clouds", and "icon":"02d")
In addition, I need to extract the values from each of the 8 "daily" objects within an array, but I'm currently stuck on how to do this.
const str = '{"lat":39.7436,"lon":-8.8071,"timezone":"Europe/Lisbon","timezone_offset":0,"current":{"dt":1643884851,"sunrise":1643874091,"sunset":1643910991,"temp":8.11,"feels_like":6.94,"pressure":1025,"humidity":87,"dew_point":6.08,"uvi":1.63,"clouds":20,"visibility":7000,"wind_speed":2.06,"wind_deg":160,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}]},"daily":[{"dt":1643889600,"sunrise":1643874091,"sunset":1643910991,"moonrise":1643880300,"moonset":1643920800,"moon_phase":0.08,"temp":{"day":9.56,"min":8.11,"max":14.8,"night":10.29,"eve":11.42,"morn":8.61},"feels_like...
Below is a snippet from the code:
[
{
dt: 1643884851,
temp: 8.11,
description: 'few clouds',
icon: '02d'
},
{
dt: 1643889600,
temp: {
day: 9.56,
min: 8.11,
max: 14.8,
night: 10.29,
eve: 11.42,
morn: 8.61
},
description: 'scattered clouds',
icon: '03d'
},
...
]
The expected output should resemble the following format:
[
{
dt: 1643884851,
temp: 8.11,
description: 'few clouds',
icon: '02d'
},
{
dt: 1643889600,
day: 9.56,
description: 'scattered clouds',
icon: '03d'
},
...
]