加载JSON文件并解析它

时间:2013-10-24 10:31:22

标签: javascript jquery json

我需要加载一个JSON文件(完成),然后解析它以访问数据以加载可折叠力布局的链接。

//Load json from local server
$.getJSON("simulator.json", function(json) {
      console.log(json);
});

1 个答案:

答案 0 :(得分:-1)

通常JSON会像这样循环:

for(a in json){
  //see a child object like this
  console.log(json[a]);
  //if it has a property, you can acccess it like so:
  link = json[a].link;
  //if it has child objects you can continue to iterate
  for(b in json[a]){
   console.log(json[a][b]);
  }
}