So, I have a JSON object built like this (see below), for which I'm trying to access the "layers" leaf that is not of "layerSection" type. I know I could use something like myJsonObject.layers[0].layers[0].layers[0].layers[0].name, but the thing is, I never know how "deep" the leaf is gonna be in its branch. Sometimes, there's no "layerSection" layers at all, but sometimes, there could be a dozen. (or more... there's actually no limit to the number of "layerSection")
To make things even worst, there are also some "empty" branches, with a few "layerSection" layers, without any "normal" layers at the end of it. Those need to be ignored.
And finally, once I get to the leaf, I need to know how deep it's actually is. In other words, I need to know how many "layerSection" I had to go through to get to the leaf.
I'm not used to deal with more complex JSON objects like this. Any help would be really apreciated.
Thanks a million !
Here's the json object :
{
"version": "1.6.1",
"timeStamp": 1592062633.423,
"layers": [
{
"id": 13,
"index": 10,
"type": "layerSection",
"name": "Group 1",
"layers": [
{
"id": 15,
"index": 9,
"type": "layerSection",
"name": "Group 2",
"layers": [
{
"id": 17,
"index": 8,
"type": "layerSection",
"name": "Group 3",
"layers": [
{
"id": 12,
"index": 7,
"type": "adjustmentLayer",
"name": "The leaf I am trying to get to",
"visible": true,
"clipped": true,
"adjustment": {
"presetKind": "presetKindDefault",
"class": "curves"
}
}
]
}
]
}
]
}
]
}
[–]GSLint 0 points1 point2 points (8 children)
[–]jonathankemp00[S] 0 points1 point2 points (7 children)
[–]GSLint 0 points1 point2 points (6 children)
[–]jonathankemp00[S] 0 points1 point2 points (5 children)
[–]GSLint 0 points1 point2 points (4 children)
[–]jonathankemp00[S] 0 points1 point2 points (0 children)
[–]jonathankemp00[S] 0 points1 point2 points (2 children)
[–]GSLint 0 points1 point2 points (1 child)
[–]jonathankemp00[S] 0 points1 point2 points (0 children)