The object below is a result of an expansion of some tree and I have to grab the descriptionPath
value and this descriptionPath
appears only in the last expanded children as shown below for the Child of Very Small Bank
children.
{
"title": "National Bank",
"bank_cd": "",
"description": {
"name": "Private Bank",
"key": "\\\\Some Key\\Path\\testing1\\testing2\\testing3"
},
"children": [{
"title": "Small Bank",
"bank_cd": "",
"description": {
"name": "Small Bank",
"key": "\\\\Some Key\\Path\\testing1\\testing2\\testing3\\Small Bank"
},
"children": [{
"title": "Very Small Bank ",
"bank_cd": "",
"description": {
"name": "Very Small Bank ",
"key": "\\\\Some Key\\Path\\testing1\\testing2\\testing3\\Small Bank\\Very Small Bank "
},
"children": [{
"title": " Child of Very Small Bank ",
"bank_cd": "123456",
"description": {
"bank_cd": "123456",
"descriptionPath": "\\A\\B\\V\\D\\text1\\text2\\text3\\text5\\"
},
"expanded": true
}],
"expanded": true
}],
"expanded": true
}],
"expanded": false
}
For example, if nothing would have been expanded, it would have looked like :
{
"title": "National Bank",
"bank_cd": "",
"description": {
"name": "Private Bank",
"descriptionPath": "\\A\\B\\V\\D\\text1\\text2\\text3\\text5\\"
},
"expanded": false
}
So, in order to grab the descriptionPath
, I was thinking of converting it to array using Object.entries method as shown in the JSFiddle here.
However, in the console.log, I am not seeing descriptionPath
anywhere. Am I following wrong approach here?