如何使用dataweave将数组的对象转置对象
如何在dataWeave中转置数组对象以获取一个JSON对象? 例如,我想
{
"date": "20201124",
"number": "NF006002CC21140000"
}
从下面的输入中获得像输出
[
{
"name": "date",
"value": "20201124",
"type": "STRING"
},
{
"name": "number",
"value": "NF006002CC21140000",
"type": "STRING"
}
]
How to transpose object of array in DataWeave to get a single JSON Object?
For example , I want to get output like
{
"date": "20201124",
"number": "NF006002CC21140000"
}
from below input
[
{
"name": "date",
"value": "20201124",
"type": "STRING"
},
{
"name": "number",
"value": "NF006002CC21140000",
"type": "STRING"
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将累加器定义为
object
的 Repard 操作。代码>(item.name):item.Value 。
You can use
reduce
operation for this by defining the accumulator as anObject
Here as the keys of the JSON is dynamically generated, you have to wrap the key expression in parentheses like
(item.name): item.value
.