How To Filter A Multi-dimension Json Object With Jquery.grep()
I have a JSON object that goes like this: {'data': [ {'name':'Alan','height':'171','weight':'66'}, {'name':'Ben','height':'182','weight':'90'}, {'name':'Chris','height':'163
Solution 1:
I think you mean this: http://jsfiddle.net/NRuM7/1/.
var obj = {"data":
[
{"name":"Alan","height":"171","weight":"66"},
{"name":"Ben","height":"182","weight":"90"},
{"name":"Chris","height":"163","weight":"71"}
]
,"school":"Dover Secondary"
};
obj.data = jQuery.grep(obj.data, function(element, index){
return element.weight > 70 && element.height > 170; // retain appropriate elements
});
Post a Comment for "How To Filter A Multi-dimension Json Object With Jquery.grep()"