I'm struggling to get the desired out put. can someone help me to find the right solution.
I tried with different specifications and noting worked. I'm facing issues when adding the parent id under respective array.
Please help here.
Input JSON:
{
"device": {
"id": "336 A6",
"shelves": [
{
"shelfID": "1",
"slots": [
{
"slotID": "1",
"cards": {
"cardID": "1",
"subSlots": [
{
"slotID": "mda-1",
"cards": {
"cardID": "1/1",
"ports": [
{
"portID": "1/1/1",
"adminStatus": "up"
},
{
"portID": "1/1/2",
"adminStatus": "up"
}
]
}
},
{
"slotID": "mda-2",
"cards": {
"cardID": "2/1",
"ports": [
{
"portID": "2/1/1",
"adminStatus": "up"
},
{
"portID": "2/1/2",
"adminStatus": "up"
}
]
}
}
]
}
},
{
"slotID": "11",
"cards": {
"cardID": "11",
"ports": [
{
"portID": "11/1/1",
"adminStatus": "up"
},
{
"portID": "11/1/2",
"adminStatus": "up"
}
]
}
}
]
},
{
"shelfID": "esat-1",
"ports": [
{
"portID": "esat-1/1/1",
"adminStatus": "down"
},
{
"portID": "esat-1/1/2",
"adminStatus": "up"
}
]
}
]
}
}
Below is the JOLT spec I tried
[
{
"operation": "shift",
"spec": {
"device": {
"shelves": {
"*": {
"ports": {
"*": "physicalResource.ports[&2]",
"@(1,shelfID)": "physicalResource.ports[&2].parentId"
},
"slots": {
"*": {
"cards": {
"ports": {
"*": "physicalResource.ports[&5]",
"@(1,cardID)": "physicalResource.ports[&5].parentId"
},
"subSlots": {
"*": {
"cards": {
"ports": {
"*": "physicalResource.ports[&8]",
"@(1,cardID)": "physicalResource.ports[&8].parentId"
}
}
}
}
}
}
}
}
}
}
}
}
]
Expected Output:
{
"physicalResource": {
"ports": [
{
"id": "1/1/1",
"parentId": "1/1",
"state": "up"
},
{
"id": "1/1/2",
"parentId": "1/1",
"state": "up"
},
{
"id": "2/1/1",
"parentId": "2/1",
"state": "up"
},
{
"id": "2/1/2",
"parentId": "2/1",
"state": "up"
},
{
"id": "11/1/1",
"parentId": "11/1",
"state": "up"
},
{
"id": "11/1/2",
"parentId": "11/1",
"state": "up"
},
{
"id": "11/1/1",
"parentId": "11/1",
"state": "up"
},
{
"id": "11/1/2",
"parentId": "11/1",
"state": "up"
},
{
"id": "esat-1/1/1",
"parentSubCardId": "esat-1",
"state": "up"
},
{
"id": "esat-1/1/2",
"parentSubCardId": "esat-1",
"state": "up"
}
]
}
}
Thanks.