我在消息转换组件中获得了一个有效负载作为输入。它是一个带有对象的数组:
[
{
"enterprise": "Samsung",
"description": "This is the Samsung enterprise",
},
{
"enterprise": "Apple",
"description": "This is the Apple enterprise ",
}
]
我有一个替换描述的变量,我想要的输出是:
[
{
"enterprise": "Samsung",
"description": "This is the var value",
},
{
"enterprise": "Apple",
"description": "This is the var value",
}
]
我尝试使用:
%dw 2.0
output application/java
---
payload map ((item, index) -> {
description: vars.descriptionValue
})
但它返回:
[
{
"description": "This is the var value",
},
{
"description": "This is the var value",
}
]
是否可以仅替换保留其余字段的描述值?避免在映射中添加其他字段。