这是我的代码中的示例 json 数组。我如何使用 getJSON 从此数组中获取数据。
"Restoration": [
{
"Easy": {
"value": "1",
"info": "This is Easy."
},
"Medium": {
"value": ".75",
"info": "This is Medium."
},
"Difficult": {
"value": ".5",
"info": "This is Difficult."
}
}
]
最佳答案
使用 jQuery jQuery.getJSON() :
$.getJSON('ajax/test.json', function(data) {
console.log(data); //see your data ( works in Chrome / FF with firebug)
console.log(data["Restoration"][0]["easy"]["value"]) //should output 1
});
关于javascript - getJSON 从这个 json 数组中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9105449/