Mule Dataweave 2 中是否有一种方法可以转换以下内容
Is there a way in Mule Dataweave 2 to transform the below
我想将 xml 格式的负载转换为 json 格式。我是 运行 Mule 4 和 Dataweave 2。
我尝试在 teammangers 上使用扁平化,但似乎没有达到预期的效果。我的来源如下
<?xml version='1.0' encoding='UTF-8'?>
<Report_Data>
<Report_Entry>
<Employee_ID>20081</Employee_ID>
<Full_Name>Richard Axel</Full_Name>
<Manager_Of_Team xmlns:wd="urn:com.workday.report/CRINT005F_Team_Listing" wd:Descriptor="Dr. Richard Axel Lab (Richard Axel)">
<ID wd:type="WID">d48b8f09725a105a7c6a31ac4ebf4c38</ID>
<ID wd:type="Organization_Reference_ID">020453</ID>
</Manager_Of_Team>
</Report_Entry>
<Report_Entry>
<Employee_ID>20787</Employee_ID>
<Full_Name>Edit Biro</Full_Name>
<Manager_Of_Team xmlns:wd="urn:com.workday.report/CRINT005F_Team_Listing" wd:Descriptor="Dr. Eero Simoncelli Lab (Edit Biro)">
<ID wd:type="WID">d48b8f09725a105a7c6bb911d60a4e3c</ID>
<ID wd:type="Organization_Reference_ID">057106</ID>
</Manager_Of_Team>
<Manager_Of_Team xmlns:wd="urn:com.workday.report/CRINT005F_Team_Listing" wd:Descriptor="Dr. Ruth Lehmann Lab (Edit Biro)">
<ID wd:type="WID">d48b8f09725a105a7c6bb69c22ff4e39</ID>
<ID wd:type="Organization_Reference_ID">057105</ID>
</Manager_Of_Team>
<Manager_Of_Team xmlns:wd="urn:com.workday.report/CRINT005F_Team_Listing" wd:Descriptor="SOO Rockefeller (Edit Biro)">
<ID wd:type="WID">d48b8f09725a105a7c6a489ccb1c4c56</ID>
<ID wd:type="Organization_Reference_ID">021001</ID>
</Manager_Of_Team>
</Report_Entry>
</Report_Data>
预期输出如下
[
{
"empl_id": "20081",
"teamManager": [
"020453"
]
},
{
"empl_id": "20787",
"teamManager": [
"057106",
"057105",
"021001"
]
}
]
谢谢。
%dw 2.0
output application/json
---
payload.Report_Data.*Report_Entry map {
empl_id: $.Employee_ID,
teamManager: $.*Manager_Of_Team..*ID filter ($.@"type"=="Organization_Reference_ID")
}
我想将 xml 格式的负载转换为 json 格式。我是 运行 Mule 4 和 Dataweave 2。 我尝试在 teammangers 上使用扁平化,但似乎没有达到预期的效果。我的来源如下
<?xml version='1.0' encoding='UTF-8'?>
<Report_Data>
<Report_Entry>
<Employee_ID>20081</Employee_ID>
<Full_Name>Richard Axel</Full_Name>
<Manager_Of_Team xmlns:wd="urn:com.workday.report/CRINT005F_Team_Listing" wd:Descriptor="Dr. Richard Axel Lab (Richard Axel)">
<ID wd:type="WID">d48b8f09725a105a7c6a31ac4ebf4c38</ID>
<ID wd:type="Organization_Reference_ID">020453</ID>
</Manager_Of_Team>
</Report_Entry>
<Report_Entry>
<Employee_ID>20787</Employee_ID>
<Full_Name>Edit Biro</Full_Name>
<Manager_Of_Team xmlns:wd="urn:com.workday.report/CRINT005F_Team_Listing" wd:Descriptor="Dr. Eero Simoncelli Lab (Edit Biro)">
<ID wd:type="WID">d48b8f09725a105a7c6bb911d60a4e3c</ID>
<ID wd:type="Organization_Reference_ID">057106</ID>
</Manager_Of_Team>
<Manager_Of_Team xmlns:wd="urn:com.workday.report/CRINT005F_Team_Listing" wd:Descriptor="Dr. Ruth Lehmann Lab (Edit Biro)">
<ID wd:type="WID">d48b8f09725a105a7c6bb69c22ff4e39</ID>
<ID wd:type="Organization_Reference_ID">057105</ID>
</Manager_Of_Team>
<Manager_Of_Team xmlns:wd="urn:com.workday.report/CRINT005F_Team_Listing" wd:Descriptor="SOO Rockefeller (Edit Biro)">
<ID wd:type="WID">d48b8f09725a105a7c6a489ccb1c4c56</ID>
<ID wd:type="Organization_Reference_ID">021001</ID>
</Manager_Of_Team>
</Report_Entry>
</Report_Data>
预期输出如下
[
{
"empl_id": "20081",
"teamManager": [
"020453"
]
},
{
"empl_id": "20787",
"teamManager": [
"057106",
"057105",
"021001"
]
}
]
谢谢。
%dw 2.0
output application/json
---
payload.Report_Data.*Report_Entry map {
empl_id: $.Employee_ID,
teamManager: $.*Manager_Of_Team..*ID filter ($.@"type"=="Organization_Reference_ID")
}