我有一個是這樣的一個JSON對象多維JSON對象:如何篩選與jQuery.grep()
{"data":
[
{"name":"Alan","height":"171","weight":"66"},
{"name":"Ben","height":"182","weight":"90"},
{"name":"Chris","height":"163","weight":"71"}
]
,"school":"Dover Secondary"
}
我想過濾的JSON對象獲得比那些更高的數據170並且重於70,然後對這個物體進行分類。從jQuery website,據我所知,過濾會很容易的線性陣列上的東西,如實現:
arr = jQuery.grep(arr, function(element, index){
return (element > 70 && index = 'weight');
});
如何過濾重量和高度同時得到這個:
{"data":
[
{"name":"Ben","height":"182","weight":"90"},
]
,"school":"Dover Secondary"
}
這不是我真正的體重和身高! –