我有一个看起来像这样的 JSON 响应
[
{
"alias": "Server1",
"hostgroup_worst_service_state": "0",
"status_history": {
"status": [
"0",
"2",
"0",
"0"
]
}
},
{
"alias": "Server2",
"hostgroup_worst_service_state": "0",
"status_history": {
"status": [
"0",
"0",
"0",
"0"
]
}
},
{
"alias": "Server3",
"hostgroup_worst_service_state": "0",
"status_history": {
"status": [
"1",
"1",
"1",
"0"
]
}
}
]
我可以使用 .each 迭代器函数轻松访问别名和 hostgroup_worst_state:
$.each(data, function(i, item) {
console.log(item.alias)
console.log(item.hostgroup_worst_service_state)
}
但是我很难访问状态数据。我需要以这种方式显示它们:
["0","2","0","0"]
["0","0","0","0"]
["1","1","1","1"]
这些值接下来将用于使用 jQuery Sparklines 显示图形。
谢谢你的帮助,