family = {
\'person1\':[{\"id\":\"1111\",\"name\":\"adam\", \"sex\":\"male\", \"born\":\"USA\"}],
\'person2\':[{\"id\":\"2222\",\"name\":\"sarah\", \"sex\":\"female\", \"born\":\"Canada\"}],
\'person3\':[{\"id\":\"3333\",\"name\":\"adam\", \"sex\":\"male\", \"born\":\"USA\"}]
};
Given the family object above, how do I extract all the properties (id, name, sex, born) of one of the person objects that have a specific id (or name) value? eg id=1111
So ideally I can get a new object personInQuestion that I can manipulate, where:
personInQuestion = {\"id\":\"1111\",\"name\":\"adam\", \"sex\":\"male\", \"born\":\"USA\"}





Rating:
The post Find an object and its properties within a larger object with javascript/jquery appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/find-an-object-and-its-properties-within-a-larger-object-with-javascriptjquery.html
No comments:
Post a Comment