我是javascript新手。这可能是基本的事情,但我坚持下去。这是我的json:
{
"statusCode": 200,
"status": "success",
"data": [
[
{
"city": "Alexandria",
"country": "Egypt",
},
{
"city": "Alexandria",
"country": "Egypt",
},]]
我要访问此:
0: {city: "Alexandria", country: "Egypt"}
1: {city: "Antalya", country: "Turkey"}
我尝试了这段代码:
getData = function (data) {
keys = Object.keys(data[0]);
data = [];
keys.forEach(function (key) {
data.push(key);
});
return data;
}
返回以下内容:
0: "0"
1: "1"
2: "2"
3: "3"
4: "4"
5: "5"
6: "6
请帮我!
慕斯709654
开心每一天1111
守候你守候我
相关分类