1function getObject(theObject) {
2 var result = null;
3 if(theObject instanceof Array) {
4 for(var i = 0; i < theObject.length; i++) {
5 result = getObject(theObject[i]);
6 if (result) {
7 break;
8 }
9 }
10 }
11 else
12 {
13 for(var prop in theObject) {
14 console.log(prop + ': ' + theObject[prop]);
15 if(prop == 'id') {
16 if(theObject[prop] == 1) {
17 return theObject;
18 }
19 }
20 if(theObject[prop] instanceof Object || theObject[prop] instanceof Array) {
21 result = getObject(theObject[prop]);
22 if (result) {
23 break;
24 }
25 }
26 }
27 }
28 return result;
29}
30