我有一个Mule流,调用两个REST API,产生两个json列表有效负载。我需要从这两个有效负载中获取合并的json列表。
我设法通过带有自定义聚合器策略的分散 - 聚集流来实现这一目标。但是,为此我必须编写的代码看起来相当混乱而且速度很慢。
有没有办法用dataweave实现这个目标?`
输入Json列表1:
[{
"ID": "1",
"firstName": "JANE""familyName": "DOE",
"Entities": [{
"ID": "515785",
"name": "UNKOWN UNITED",
"callSign": "UU"
}]
},
{
"ID": "2",
"firstName": "JOHN",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "515785",
"name": "UNKOWN UNITED",
"callSign": "UU"
}]
}]
输入Json list 2:
[{
"ID": "1",
"firstName": "JANE",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "8916514",
"name": "UNKOWN INCORPORATED",
"callSign": "UI"
}]
},
{
"ID": "4",
"firstName": "JAKE",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "8916514",
"name": "UNKOWN INCORPORATED",
"callSign": "UI"
}]
}]
所需的输出是没有重复ID的合并列表:
[{
"ID": "1",
"firstName": "JANE",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "515785",
"name": "UNKOWN UNITED",
"callSign": "UU"
},
{
"Entities_ID": "8916514",
"name": "UNKOWN INCORPORATED",
"callSign": "UI"
}]
},
{
"ID": "2",
"firstName": "JOHN",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "515785",
"name": "UNKOWN UNITED",
"callSign": "UU"
}]
},
{
"ID": "4",
"firstName": "JAKE",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "8916514",
"name": "UNKOWN INCORPORATED",
"callSign": "UI"
}]
}]
答案 0 :(得分:0)
这适用于dataweave,其中payload是list1,flowVars.list2是list2
Dim ZipFileObj As Variant
Set ZipFileObj = App.Namespace(ZipFile)
For Each item In ZipFileObj.Items
If LCase(item) Like LCase("*.xml") Then
'This is where I need a way to read
'the contents of the file as a string.
'Then I can use
'map.ImportXml(contents)
End If
Next item
希望这有帮助