[英]JOLT array transformation: add key in all objects in list
我有一個輸入 object:
{
"array": [
{
"id": 1
},
{
"id": 2
}
],
"object": {
"fixed-value": "some-value"
}
}
我想把它變成:
{
"NewObject" : [ {
"objectId" : 1,
"fixedValue": "some-value"
}, {
"objectId" : 2,
"fixedValue": "some-value"
} ]
}
我制作了這個JOLT
規范,它移動了array
中的對象列表,但我無法在所有這些對象中添加fixed-value
鍵:
[
{
"operation": "shift",
"spec": {
"array": {
"*": {
"id": "NewObject[&1].objectId"
}
}
}
}
]
檢查這個規格,
遍歷回根然后 select 的固定值,
"@(2,object.fixed-value)": "NewObject[&1].fixedValue"
[
{
"operation": "shift",
"spec": {
"array": {
"*": {
"id": "NewObject[&1].objectId",
"@(2,object.fixed-value)": "NewObject[&1].fixedValue"
}
}
}
}
]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.