Input:
{
"order": {
"order_items": [
{
"id": "1",
"name": "one"
},
{
"id": "2",
"name": "two"
}
],
"default_item": {
"id": "0",
"name": "zero"
}
}
}
Desired output:
{
"invoices" : [ {
"id" : "1",
"name" : "one"
}, {
"id" : "2",
"name" : "two"
}, {
"id" : "0",
"name" : "zero"
} ]
}
I am achieving this by using the following spec:
[
{
"operation": "shift",
"spec": {
"order": {
"order_items": {
"*": {
"id": "invoices[&1].id",
"name": "invoices[&1].name"
}
},
"default_item": {
"id": "invoices[2].id",
"name": "invoices[2].name"
}
}
}
}
]
But the problem with the above spec is that the input array can have any number of elements.So I can not default the default element to third index like the above spec. I would rather place the default element at the 0 index and start the other elements from input array from index 1 of the output array. How do we do this. Thanks a lot for your help
Input:
Desired output:
I am achieving this by using the following spec:
But the problem with the above spec is that the input array can have any number of elements.So I can not default the default element to third index like the above spec. I would rather place the default element at the 0 index and start the other elements from input array from index 1 of the output array. How do we do this. Thanks a lot for your help