以下是我正在使用的對象的簡短示例。如何使用JavaScript或jQuery查找多維JSON對象中特定節點的最高值
{
"myservices": [
{
"name": "oozie",
"hostidn": "1",
"details": "failed process health monitor....",
"currstatus": "Warning",
"currstatusclass": "warning"
},
{
"name": "oozie",
"hostidn": "2",
"details": "failed process health monitor....",
"currstatus": "Warning",
"currstatusclass": "warning"
},
{
"name": "oozie",
"hostidn": "3",
"details": "failed process health monitor....",
"currstatus": "Warning",
"currstatusclass": "warning"
},
{
"name": "oozie",
"hostidn": "4",
"details": "failed process health monitor....",
"currstatus": "Warning",
"currstatusclass": "warning"
},
{
"name": "oozie",
"hostidn": "5",
"details": "failed process health monitor....",
"currstatus": "Warning",
"currstatusclass": "warning"
},
{
"name": "single-namenode",
"hostidn": "2",
"details": "failed process health monitor....",
"currstatus": "Warning",
"currstatusclass": "warning"
}
]
}
我最終想要查找最高「hostidn」就是通過這些運行和顯示在他們面前。 hostidn是第N個數字,它可以是唯一的數字,也可以是數百個數字,其間有幾個重複。我的目標是找到最高的一個,並根據它做一個for或while循環,以將它們組合在一起進行視覺展示。示例通知我在下面有一個hostidn,其中所有其他的都有自己的號碼。我想將這兩個在一起放在一個盒子中用於顯示,但在這種情況下有5個不同的hostidn。我不知道,也許我正在想它錯了,我會採取建議,但是。
是要顯示所有具有最高hostidn的那些,包括易受騙的人的問題? – Evan
你想得到最高的數字還是發生得最多的數字?無論如何,你必須迭代數組並比較數字,那麼你的實際問題是什麼? –
迭代........... – Rafay