例如,如果我有JSON文件,如:
{
"update" : {
"email@gmail.com":{
"1234": {"notfication": "This is testing 1","url": "http://example1.com"},
"4567": {"notfication": "This is testing 3","url": "http://facebook.com"}
},
"testing@gmail.com":{
"abcd": {"notfication": "This is testing 1","url": "http://example2.com"},
"efgh": {"notfication": "This is testing 3","url": "http://facebook.com"}
}
}
}
是否可以要求服务器返回文本:“email@gmail.com”和“testing@gmail.com”?
谢谢
答案 0 :(得分:0)
var obj = {
"update" : {
"email@gmail.com":{
"1234": {"notfication": "This is testing 1","url": "http://example1.com"},
"4567": {"notfication": "This is testing 3","url": "http://facebook.com"}
},
"testing@gmail.com":{
"abcd": {"notfication": "This is testing 1","url": "http://example2.com"},
"efgh": {"notfication": "This is testing 3","url": "http://facebook.com"}
}
}
};
var keys = Object.keys(obj.update);
console.log(keys[0]);
console.log(keys[1]);
另见Ranga的回答here。