Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //find an object on json data
- function getObject(obj, key, val){
- var objects = [];
- for(var i in obj){
- if(!obj.hasOwnProperty(i)) continue;
- if(typeof obj[i] == 'object'){
- objects = objects.concat(getObject(obj[i], key, val));
- } else if(i == key && obj[key] == val){
- objects.push(obj);
- }
- }
- return objects;
- }
Advertisement
Add Comment
Please, Sign In to add comment