Mule 4 Dataweave:从脚本输出到 JSON 的数组
执行脚本模块后,我得到以下输出:
[
"0": [
"0": ["A","B","C"],
"1": ["D","E","F"]
],
"1": [
"0": ["A","B","C"],
"1": ["D","E","F"],
"2": ["G","H","I"]
],
"2": [
"0": ["A","B","C"],
"1": ["D","E","F"],
"2": ["G","H","I"]
]
]
我只想获取值,而不是键。所以预期的输出是:
[
[
["A","B","C"],
["D","E","F"]
],
[
["A","B","C"],
["D","E","F"],
["G","H","I"]
],
[
["A","B","C"],
["D","E","F"],
["G","H","I"]
]
]
我尝试使用map函数和valuesOf函数,但没有任何运气。
谢谢!
After a script module execution, I get the output below:
[
"0": [
"0": ["A","B","C"],
"1": ["D","E","F"]
],
"1": [
"0": ["A","B","C"],
"1": ["D","E","F"],
"2": ["G","H","I"]
],
"2": [
"0": ["A","B","C"],
"1": ["D","E","F"],
"2": ["G","H","I"]
]
]
And I would like to get only the values, not the keys. So the expected output would be:
[
[
["A","B","C"],
["D","E","F"]
],
[
["A","B","C"],
["D","E","F"],
["G","H","I"]
],
[
["A","B","C"],
["D","E","F"],
["G","H","I"]
]
]
I tried to use the map function and the valuesOf function, but without any luck.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设输出看起来像这样的另一个选项,
此脚本将其转换为您想要的
输出
Another option supposing the output looks like this
this script turns it into your desired output
output
假设输入和第一个子级确实是对象,您可以在顶层使用 pluck() 来提取对象数组,然后映射每个子级以再次使用 pluck() 。
输入:
脚本:
输出:
Assuming the input and the first childs are really objects, you can use pluck() at the top level to extract as an array of objects, then map each of the childs to use pluck() again.
Input:
Script:
Output: