【发布时间】:2018-05-02 13:20:05
【问题描述】:
我正在尝试从外部 json 文件中获取值并将一些值保存在数组中。我的代码:
$.getJSON("https://link.to.my.json", function(data) {
console.log(data); // this will show the info it in console
});
所以我可以从 json 获取数据,但我不确定如何将名字和姓氏添加到数组 [bob rooppo,peter sticker]。任何帮助,将不胜感激 和我的 json:
{
"users": [
{
"test": "123",
"name": {
"first": "bob",
"last": "roppo"
},
"email": "bob@gmail.com",
"phone": "+123456789"
},
{
"test": "124",
"name": {
"first": "peter",
"last": "sticer"
},
"email": "peter@gmail.com",
"phone": "+123456789"
}
]
}
【问题讨论】:
标签: javascript arrays json ajax