Jolt to transform muliple values in an array
I am trying to transform a json using jolt where i am moving the array inside serviceCharacteristic to outside of service {}, eventually i plan to move to respective positions
{
"serviceOrderItem": [
{
"action": "modify",
"id": "0965f63b-db26-4397-b222-190a891838f0",
"service": {
"href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
"id": "adaptiveNetworkSite",
"serviceCharacteristic": [
{
"name": "modifyPath",
"value": [
{
"op": "add",
"path": "$.supportingService",
"value": {}
},
{
"op": "sub",
"path": "$.supportingService",
"value": {}
}
]
}
]
}
},
{
"action": "create",
"id": "0965f63b-db26-4397-b222-190a891838f0",
"service": {
"href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
"id": "adaptiveNetworkSite",
"serviceCharacteristic": [
{
"name": "modifyPath",
"value": [
{
"op": "abcd",
"path": "$.supportingService",
"value": {
"state": "active"
}
},
{
"op": "efgh",
"path": "$.supportingService",
"value": {
"state": "active"
}
}
]
}
]
}
}
]
}
desired output is
{
"serviceOrderItem": [
{
"action": "modify",
"id": "0965f63b-db26-4397-b222-190a891838f0",
"service": {
"href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
"id": "adaptiveNetworkSite"
}
"modifyPath": [
{
"op": "add",
"path": "$.supportingService",
"value": {}
},
{
"op": "sub",
"path": "$.supportingService",
"value": {}
}
]
},
{
"action": "create",
"id": "0965f63b-db26-4397-b222-190a891838f0",
"service": {
"href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
"id": "adaptiveNetworkSite"
}
"modifyPath": [
{
"op": "abcd",
"path": "$.supportingService",
"value": {
"state": "active"
}
},
{
"op": "efgh",
"path": "$.supportingService",
"value": {
"state": "active"
}
}
]
}
}
]
}
my Jolt is working only when there is single array in modifyPath
[{
"operation": "shift",
"spec": {
"*": "&",
"serviceOrderItem": {
"*": {
"*": "serviceOrderItem[&1].&",
"service": {
"*": "serviceOrderItem[&2].service.&",
"serviceCharacteristic": {
"*": {
"value": "@(1,name)"
}
}
}
}
}
}
}, {
"operation": "shift",
"spec": {
"*": "&",
"modifyPath": {
"@(1,modifyPath)": "serviceOrderItem[0].modifyPath"
},
"supportingService": {
"@(1,supportingService)": "serviceOrderItem[0].service.supportingService"
}
}
}]
when multiple array is given it shuffles the array,
"serviceOrderItem" : [ {
"action" : "modify",
"id" : "0965f63b-db26-4397-b222-190a891838f0",
"modifyPath" : [ {
"op" : "add",
"path" : "$.supportingService",
"value" : { }
}, {
"op" : "sub",
"path" : "$.supportingService",
"value" : { }
}, [ {
"op" : "abcd",
"path" : "$.supportingService",
"value" : {
"state" : "active"
}
}, {
"op" : "efgh",
"path" : "$.supportingService",
"value" : {
"state" : "active"
}
} ] ],
"service" : {
"href" : "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
"id" : "adaptiveNetworkSite"
}
}, {
"action" : "create",
"id" : "0965f63b-db26-4397-b222-190a891838f0",
"service" : {
"href" : "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
"id" : "adaptiveNetworkSite"
}
} ]
}
please advise , thank you for you time

