jolt transform ( add array elements to a different existing array )
Hello , can anyone help with a spec to transform this JSON input to the desired output .
JSON INPUT
==========
{
"saleStrategy": {
"strategy": "strategy1",
"code": "code1"
},
"saleStrategyCollection": [
{
"id": "2",
"saleStrategy": {
"strategy": "strategy2",
"code": "code2"
}
},
{
"id": "3",
"saleStrategy": {
"strategy": "strategy3",
"code": "code3"
}
}
]
}
== desired output json ==
{
"saleStrategies" : [
{
"strategy" : "strategy1",
"code" : "code1"
},
{
"strategy" : "strategy2",
"code" : "code2"
},
{
"strategy" : "strategy3",
"code" : "code3"
}
]
}
== current spec === // this currently only transforms the initial single saleStrategy object to an array called salesStrategies. Desired output above shows that If there is a saleStrategy array also present in the input JSON , then the spec needs to add the saleStrategy objects within that array to the salesStrategies output array as well . NOTE the transform must not include "id" in the output.
[
{
"operation": "shift",
"spec": {
"saleStrategy": {
"strategy": "saleStrategies[0].strategy",
"code": "saleStrategies[0].code"
}
}
}
]
Any suggestions would be greatly appreciated. Thanks in advance, Rob.

