You can solve that in different ways.
1. This spec is more understandable:
- Order your list with the
id
value as a key in the shift
operation: @(1,id)
- Concat
firstName
and lastName
in the modify-overwrite-beta
operation: =concat(@(1,firstName),' ',@(1,lastName))
- Remove unused keys in the
remove
operation: id, firstName, lastName
[
{
"operation": "shift",
"spec": {
"*": { // index of the array: 1, 2
"*": { // data object
"*": "@(1,id).&" // value of id in the current object: 111, 222
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": { // ids: 111, 222
"fullName": "=concat(@(1,firstName),' ',@(1,lastName))"
}
}
},
{
"operation": "remove",
"spec": {
"*": { // ids: 111, 222
"id": "",
"firstName": "",
"lastName": ""
}
}
}
]
2. This spec is shorter:
- Concat
firstName
and lastName
in the modify-overwrite-beta
operation: =concat(@(1,firstName),' ',@(1,lastName))
- Get the value of
id
as a key and put fullname
in it: key @(1,id).fullName
, value @(0,fullName)
[
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"*": {
"fullName": "=concat(@(1,firstName),' ',@(1,lastName))"
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"@(0,fullName)": "@(1,id).fullName"
}
}
}
}
]
The following image can help more:
