JSFiddle - React, Tailwind, and code Playground
JavaScript
var data = {
"event": [{
"query": {
"id": [{
"timestamp_usec": "1316596939223064"
}],
"query_text": "sometext"
}
}, {
"query": {
"id": [{
"timestamp_usec": "1316318681908642",
"type": "sometype",
"abc": "someabc"
}, {
"timestamp_usec": "1316318679366796"
}],
"query_text": "someothertext"
}
}
//...More...//
]
};
var data = {
"event": [{
"query": {
"id": [{
"timestamp_usec": "1316596939223064"
}],
"query_text": "sometext"
}
}, {
"query": {
"id": [{
"timestamp_usec": "1316318681908642",
"type": "sometype",
"abc": "someabc"
}, {
"timestamp_usec": "1316318679366796"
}],
"query_text": "someothertext"
}
}
//...More...//
]
};
var name = "abc";
var check = function check(obj, name) {
if (/Object/.test(obj.constructor.toString()) && obj.hasOwnProperty(name)) {
console.log(name + " found")
} else {
console.log(name + " not found")
}
};
$.each(data.event, function(key, value) {
check(value, name)
$.each(value.query, function(k, v) {
check(v, name);
if (typeof v === "object") {
$.each(v, function(_k, _v) {
check(_v, name)
})
}
})
});