你可以用不同的方法来解决这个问题.
1. This spec is more understandable:个
- 在
shift
操作中,以值id
为关键字对列表进行排序:@(1,id)
modify-overwrite-beta
运算中的连接firstName
和lastName
:=concat(@(1,firstName),' ',@(1,lastName))
- 删除
remove
操作中未使用的关键点: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:个
modify-overwrite-beta
运算中的连接firstName
和lastName
:=concat(@(1,firstName),' ',@(1,lastName))
- 获取值
id
作为键,然后将fullname
放入其中: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:个