我正在尝试修改输入内容,并使用'-indexNum'为每个对象添加一个ID,但这似乎不起作用。这里我发布了代码。
我的输入
{
"employees": [{
"f_name": "tom",
"l_name": "smith"
},
{
"f_name": "don",
"l_name": "jones"
}
]
}
预期o / p:
{
"employees": [{
"firstName": "tom",
"lastName": "smith",
"test": "emp-"
}, {
"firstName": "don",
"lastName": "jones",
"test": "emp-"
}]
}
我的规格
[{
"operation": "shift",
"spec": {
"employees": {
"*": {
"f_name": "employees[&1].firstName",
"l_name": "employees[&1].lastName"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"employees": {
"*": {
"test": "=concat('emp-',)"
}
}
}
}]
我正在尝试修改输入内容,并使用'-indexNum'为每个对象添加一个ID。有人可以建议我帮忙。
答案 0 :(得分:0)
规格
[
{
"operation": "shift",
"spec": {
"employees": {
"*": {
"$": "employees[&1].employeeNum",
"f_name": "employees[&1].firstName",
"l_name": "employees[&1].lastName"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"employees": {
"*": {
"employeeNum": "=concat('emp-',@(1,employeeNum))"
}
}
}
}
]