Support Questions
Find answers, ask questions, and share your expertise

JOLT Spec with grouping Nested arrays by appending parent key value

JOLT Spec with grouping Nested arrays by appending parent key value

Explorer

Hello JOLT experts,

     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:

{
"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"
}
]
}
]
}
}

 

 

    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,

Lokeawar.