我有一个对象,它包含带有对象的数组。我该如何实施这种转变?
I have an object it contains array with object. How can I implement this transformation?
输入
{
"address": [{
"extraId": "AB",
"globe": "0980098",
"newAddress": [{
"name": "addressName",
"value": "XY,0980980980"
}]
}],
"products": [{
"productName": "ACC"
},
{
"productName": "SSSS"
},
{
"productName": "DDDD"
},
{
"productName": "FFF"
}
],
"additionaldata": [{
"name": "asasa",
"value": "23232"
}]
}
输出
{
"extraId": "AB",
"globe": "0980098",
"newAddress": [{
"name": "addressName",
"value": "XY,0980980980"
}],
"products": [{
"productName": "ACC"
},
{
"productName": "SSSS"
},
{
"productName": "DDDD"
},
{
"productName": "FFF"
}
],
"additionaldata": [{
"name": "asasa",
"value": "23232"
}]
}
%dw 2.0
output application/json
var address = payload.address[0]
---
address ++ (payload - "address")
输入
{
"address": [{
"extraId": "AB",
"globe": "0980098",
"newAddress": [{
"name": "addressName",
"value": "XY,0980980980"
}]
}],
"products": [{
"productName": "ACC"
},
{
"productName": "SSSS"
},
{
"productName": "DDDD"
},
{
"productName": "FFF"
}
],
"additionaldata": [{
"name": "asasa",
"value": "23232"
}]
}
输出
{
"extraId": "AB",
"globe": "0980098",
"newAddress": [{
"name": "addressName",
"value": "XY,0980980980"
}],
"products": [{
"productName": "ACC"
},
{
"productName": "SSSS"
},
{
"productName": "DDDD"
},
{
"productName": "FFF"
}
],
"additionaldata": [{
"name": "asasa",
"value": "23232"
}]
}
%dw 2.0
output application/json
var address = payload.address[0]
---
address ++ (payload - "address")