日期:2014-05-16  浏览次数:20428 次

如何在javascript里解析json数据
({status:0,
  errorMessage:"",
  retryCode:51,
  data:[
  {"root":[
  {"head":{"REH_BOTEL":"","REH_DFAX":""},"body":[{"RED_PHO_FIL":"","RED_STAX_AMT":""}]},
  {"head":{"REH_BOTEL":"","REH_DFAX":""},"body":[{"RED_PHO_FIL":"","RED_STAX_AMT":""}]}
  ]}
  ],
  count:3
})
上面是java生成的json数据怎么取得dada里面的数据?像取得status就直接用json.status就可以,但 data里面又包含有数组,该怎么取

请问 在jsp:代码中
$.getJSON(url,
function(json){
var results = json.status;
if(results =="1" || results=="2") {
document.all["error"].innerHTML=json.errorMessage;
  } else {
  var str = "({";
  str += "status:" + json.status + ",";
  str += "errorMessage:\"" + json.errorMessage + "\",";
  str += "retryCode:" + json.retryCode+",";
  str += "data:" + json.data[0] +",";
  str += "count:" + json.count + "";
  str += "})";
  }
});

------解决方案--------------------
data的结构就再您眼前 还不能取吗
------解决方案--------------------
data[0]
------解决方案--------------------
json.data[0].root[i].head...