Can someone please help with Jolt transformation taking the following into consideration
- No limitation on the depth of children array, i.e though the example below shows a maximum depth on 2 levels Adam -> John -> Sarah this hierarchy can extend to any level
- Rename name -> childname, title -> childtitle if the node is present in children array in the hierarchy
Input:
{
"person": "Adam",
"personTitle": "MR",
"children": [
{
"name": "John",
"title": "MR",
"children": [
{
"name": "Sarah",
"title": "MR",
"children": [
]
}
]
},
{
"name": "Jimmy",
"title": "MR",
"children": [
{
"name": "Stephen",
"title": "MR",
"children": [
]
}
]
}
]
}
Output:
{
"person": "Adam",
"personTitle": "MR",
"children": [
{
"childname": "John",
"childtitle": "MR",
"children": [
{
"childname": "Sarah",
"childtitle": "MR",
"children": [
]
}
]
},
{
"childname": "Jimmy",
"childtitle": "MR",
"children": [
{
"childname": "Stephen",
"childtitle": "MR"
}
]
}
]
}
It's not possible to do unlimited deep exploration with Jolt. I see two solutions: (1) set a sufficiently but limited depth with the jolt specification or (2) use the recursivity of a programming language (without jolt).
For solution 2, I solved a problem this way:
Test :