使用jQuery从JSON数据中获取价值

时间:2014-03-08 10:56:37

标签: javascript jquery json

当我提醒结果时,我得到了以下JSON数据:

var results = JSON.stringify(result.results);
alert(results);

[{
    "test": "Connect_Disconnect222222",
    "jobid": "59",
    "os": "Windows NTeeeeeee",
    "report": "Verify Wireless Interface presenttttttttt and state is Disconnected:OK<br>Verify Profile not present on the Client:OK Client:OK<br>Verify Profile Not Present on the Client:OKffffffffffff<br>"
}]

如何从该数据中获取值reporttestjobid

2 个答案:

答案 0 :(得分:3)

result.results是一个数组对象,因此您需要获取数组中的第一项,然后获取其属性

var record = result.results[0];
alert(record.test)
alert(record.jobid)
alert(record.report)

答案 1 :(得分:0)

当你使用JsonArray时,你必须定义行号,例如

alert(results[0].report);
alert(results[0].test);
alert(results[0].jobid);