获取JSON列表树值

时间:2016-09-15 05:49:33

标签: jquery json

{ "httpCode": "200",
  "status": "success",
  "message": "SuccessFully Listed",
  "details": {"result": [{"Id": 1,"Key": "B33C78A0-C598-4071-863B-EF6B6978F790","Name": "Windows","ShortName": "Win"}]}}

这是我的Json结果我需要获取结果列表。如何获得结果?

2 个答案:

答案 0 :(得分:0)

使用点运算符

var obj = { "httpCode": "200",
  "status": "success",
  "message": "SuccessFully Listed",
  "details": {"result": [{"Id": 1,"Key": "B33C78A0-C598-4071-863B-EF6B6978F790","Name": "Windows","ShortName": "Win"}]}}

console.log(obj.details.result[0].Name)

答案 1 :(得分:0)

如果是数组格式,你可以解析json

var det = JSON.parse('{ "httpCode": "200",
  "status": "success",
  "message": "SuccessFully Listed",
  "details": {"result": [{"Id": 1,"Key": "B33C78A0-C598-4071-863B-EF6B6978F790","Name": "Windows","ShortName": "Win"}]}}');

alert(det['details']['result']);