JSFiddle - React, Tailwind, and code Playground
by Mikhail
JavaScript
var obj = {
"coord": {
"lon": 73.86,
"lat": 18.52
},
"sys": {
"message": 0.0083,
"country": "IN",
"sunrise": 1436142797,
"sunset": 1436190324
},
"weather": [
{
"id": 500,
"main": "Rain",
"description": "light rain",
"icon": "10d"
}
],
"base": "stations",
"main": {
"temp": 298.644,
"temp_min": 298.644,
"temp_max": 298.644,
"pressure": 948.79,
"sea_level": 1018.56,
"grnd_level": 948.79,
"humidity": 78
},
"wind": {
"speed": 6.46,
"deg": 253.501
},
"clouds": {
"all": 68
},
"rain": {
"3h": 0.225
},
"dt": 1436180142,
"id": 1259229,
"name": "Pune",
"cod": 200
};
function listKeys(data){
for (var key in data) {
if (data.hasOwnProperty(key)) {
if((typeof data[key]).toLowerCase() != 'object'){
console.log(key, data[key])
} else {
console.log(key + ': ');
listKeys(data[key]);
}
}
}
}
listKeys(obj);