這是我的第一篇文章:我一直在尋找一個相當長的解決方案。如何過濾多維JavaScript數組
所以我有這樣的JSON數據:
var object = [{
"nid": "31",
"0": {
"tid": "20",
"name": "Bench Press",
"objectDate": "2012-02-08",
"goal": "rep",
"result": "55.00",
"comments": "sick!",
"maxload": "250"
},
"1": {
"tid": "22",
"name": "Back Squat",
"objectDate": "2012-02-08",
"goal": "time",
"result": "8.00",
"comments": "i was tired.",
"maxload": "310"
}},
{
"nid": "30",
"0": {
"tid": "19",
"name": "Fran",
"objectDate": "2012-02-07",
"goal": "time",
"result": "5.00",
"comments": null
}}];
而且我想通過名字來過濾。舉例來說,如果我申請一個過濾器的名稱「弗蘭」,我想是這樣的:
[0] => Array
(
[tid] => 19
[name] => Fran
[objectDate] => 2012-02-07
[goal] => time
[result] => 5.00
[comments] =>
)
[1] => Array
(
[tid] => 19
[name] => Fran
[objectDate] => 2012-02-08
[goal] => rep
[result] => 55.00
[comments] => woohoo!
)
是否有可能實現嗎?任何幫助將不勝感激! :>
您可能對我的JSON.search API感興趣,它的速度比$ .grep快5倍,並允許您使用正則表達式進行搜索。請參閱http://json.spiritway.co/ – mgwhitfield 2015-05-08 20:48:20