JSFiddle - React, Tailwind, and code Playground
by Jang Won Woong
HTML
<script src="http://defiantjs.com/defiant.js/dist/defiant-latest.min.js"></script>
JavaScript
var myNodes = [
{
"id": 4,
"name": 'name_of_4',
"children": [
{
"id": 1,
"name": 'name_of_1',
"children": []
},
{
"id": 3,
"name": 'name_of_3',
"children": []
}
]
},
{
"id": 2,
"name": 'name_of_2',
"children": []
},
{
"id": 6,
"name": 'name_of_6',
"children": [
{
"id": 5,
"name": 'name_of_5',
"children": []
}
]
}
],
found = JSON.search(myNodes, '//*[id=1]');
console.log( found );
// name_of_6