javascript - getJSON 从这个 json 数组中获取数据

标签 javascript json jquery getjson

这是我的代码中的示例 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/

相关文章:

java - 从 InputStreamReader 将 Json 转换为 gson

javascript - 使用 jquery 在单击按钮时加载 html 文件时遇到困难

javascript - 使用 jQuery 查找和替换 HTML 字符串

javascript - 如何通过 Awesomium 库从 javascript 函数返回值?

javascript - 将旧值作为 "ghost"thumb 添加到 <input type ="range"> Slider

javascript - 什么是任意数据/JSON?

jquery - 禁用 materialize.css 模态页脚按钮

javascript - 如何使用 Ajax 发送 header

javascript - 如何从一开始就进行非贪婪搜索

javascript - 使用 jQuery 通过函数获取 JSON