Given a json such :
var WNES_list = {
"India":{ "W": 67.0, "N":37.5, "E": 99.0, "S": 5.0, "vert_%": 106 },
};
I know how to access values :
var myValue = WNES_list.India.W;
How to access to a key such W
, or India
?
Given a json such :
var WNES_list = {
"India":{ "W": 67.0, "N":37.5, "E": 99.0, "S": 5.0, "vert_%": 106 },
};
I know how to access values :
var myValue = WNES_list.India.W;
How to access to a key such W
, or India
?
You can use a for loop to access the key
for (var key in WNES_list) {
var obj = WNES_list[key];
console.log(key); // logs : India, France
for (var k in obj) {
if (obj.hasOwnProperty(k)) {
console.log(k);
}
}
}