find key in nested json object
function getObject(theObject) {
var result = null;
if(theObject instanceof Array) {
for(var i = 0; i < theObject.length; i++) {
result = getObject(theObject[i]);
if (result) {
break;
}
}
}
else
{
for(var prop in theObject) {
console.log(prop + ': ' + theObject[prop]);
if(prop == 'id') {
if(theObject[prop] == 1) {
return theObject;
}
}
if(theObject[prop] instanceof Object || theObject[prop] instanceof Array) {
result = getObject(theObject[prop]);
if (result) {
break;
}
}
}
}
return result;
}
Also in JavaScript:
- react native touchableopacity disable
- how can prevent morgan to work in test enviroment
- face-api without projects
- angularjs iframe src binding
- immutable values
- how to proxy enable in server nodejs
- javascript get 24 hour time
- javascript open new window
- cannot find module @babel/compat-data/data/corejs3-shipped-proposals
- create functional component react
- select all checkboxes html js
- universal apollo kit
- input set variable angular
- how to use flatlist keyextractor
- javascript template string
- getusermedia example
- js load img
- knex.js insert two rows
- .map function
- angular input press enter
- datepicker select date programmatically bootstrap
- are you sure javascript
- singly even magic square creation algorithm
- cordova delete cache