我有以下格式的 JSON 数据:
[
{
"_index": "servers",
"_id": "server1",
"_score": 1,
"_source": {
"list": {
"key1": {
"c1": {
"check_status": "PASSED",
"check_name": "c1",
"error_msg": "NOERRORS",
"check_state": "OK"
},
"c2": {
"check_status": "PASSED",
"check_name": "c2",
"error_msg": "NO ERRORS",
"check_state": "OK"
}
},
"key2": {
"c11": {
"check_status": "PASSED",
"check_name": "c11",
"error_msg": "NO ERRORS",
"check_state": "OK"
},
"c22": {
"check_status": "PASSED",
"check_name": "c22",
"error_msg": "NO ERRORS",
"check_state": "OK"
}
}
},
"Date Universal": "2015-10-19T10:14:03Z",
"SERVER EXISTENCE": "active"
}
},
{
"_index": "servers",
"_id": "server2",
"_score": 1,
"_source": {
"list": {
"key1": {
"c1": {
"check_status": "PASSED",
"check_name": "c1",
"error_msg": "NOERRORS",
"check_state": "OK"
},
"c2": {
"check_status": "PASSED",
"check_name": "c2",
"error_msg": "NO ERRORS",
"check_state": "OK"
}
},
"key2": {
"c11": {
"check_status": "PASSED",
"check_name": "c11",
"error_msg": "NO ERRORS",
"check_state": "OK"
},
"c22": {
"check_status": "PASSED",
"check_name": "c22",
"error_msg": "NO ERRORS",
"check_state": "OK"
}
}
},
"Date Universal": "2015-10-19T10:14:03Z",
"SERVER EXISTENCE": "active"
}
}
]
我要查找的 html 表应该为每个服务器提供一条记录,并且如果在表的同一行中存在特定服务器的所有错误,它应该显示所有错误。
我在这里为代码参考创建了一个 JSfiddle,这个 fiddle 不是确切的脚本。我可以将服务器名称和其他信息拉到表中。但是循环检查并找出所有失败的检查是我很难找到的。有人可以帮帮我吗?
我正在寻找一个小提琴输出,显示每个服务器的嵌套 JSON 对象的迭代,并仅将失败的检查和相关的错误打印为表中的输出。有 1k 个服务器,每个服务器都有 key1 检查 20 和 key2 检查 20。控制器代码是这样的
var app=angular.module('angmod', []);
app.controller('ctrl1',function($scope,$http,$interval){
load_data();
$interval(function(){
load_data();
},5000);
function load_data(){
data=[{
"_index":"servers",
"_id":"server1",
"_score":1,
"_source":{
"list":{
"key1":{"c1"{"check_status":"PASSED","check_name":"c1","error_msg":"NOERRORS","check_state":"OK"},"c2":{"check_status":"PASSED","check_name":"c2","error_msg":"NO ERRORS","check_state":"OK"}},
"key2":{"c11":{"check_status":"PASSED","check_name":"c11","error_msg":"NO ERRORS","check_state":"OK"},"c22":{"check_status":"PASSED","check_name":"c22","error_msg":"NO ERRORS","check_state":"OK"}}
},
"Date Universal":"2015-10-19T10:14:03Z",
"SERVER EXISTENCE":"active"}
}],
"Date Universal":"2015-10-19T10:14:03Z",
"SERVER EXISTENCE":"active"}
},{"_index":"servers",
"_id":"server2",
"_score":1,
"_source":{
"list":{
"key1":{"c1"{"check_status":"PASSED","check_name":"c1","error_msg":"NOERRORS","check_state":"OK"},"c2":{"check_status":"PASSED","check_name":"c2","error_msg":"NO ERRORS","check_state":"OK"}},
"key2":{"c11":{"check_status":"PASSED","check_name":"c11","error_msg":"NO ERRORS","check_state":"OK"},"c22":{"check_status":"PASSED","check_name":"c22","error_msg":"NO ERRORS","check_state":"OK"}}
},
"Date Universal":"2015-10-19T10:14:03Z",
"SERVER EXISTENCE":"active"}
}]
}]
$scope.qwe=data;
});
};
})
谁能解释一下逻辑???