【发布时间】:2021-10-22 01:59:36
【问题描述】:
我是 MuleSoft 的新手,正在为 DataWeave 的场景苦苦挣扎。有人可以帮助我优化合并两个有效负载以获得所需输出的方法吗? payload1 有字段,payload2 有这些字段的规则集; 我们需要为每个领域制定相应的规则;例如,'name' 字段需要与 'name' 规则合并,类似地,'roll' 字段需要与 'roll' 规则合并(它们可能是单个字段的多个规则);等等:
数据:
有效载荷1 =
[
{
"ID" : "1",
"Name" : "ABC",
"Roll" : 123,
"Address" : "PQR-234",
"Standard" : "5"
},
{
"ID" : "2",
"Name" : "PQR",
"Roll" : 456,
"Address" : "REC-678",
"Standard" : "7"
},.
.
.
]
有效载荷2 =
[
{
"field" : "Name",
"field-Type": "String",
"operator": "Not-In-List" ,
"condition-Operand-Type": "",
"error-Message": "Name - Invalid Value: Name not found in the list."
},
{
"field" : "Name",
"field-Type": "String",
"operator": "invalid" ,
"condition-Operand-Type": "",
"error-Message": "Name - Invalid Value: There cannot be special char in a name."
},
{
"field" : "Roll",
"field-Type": "String",
"operator": "Not-In-List" ,
"condition-Operand-Type": "",
"error-Message": "Roll - Invalid Value: Roll not found in the list."
},
{
"field" : "Address",
"field-Type": "String",
"operator": "Not-In-List" ,
"condition-Operand-Type": "",
"error-Message": "Address - Invalid Value: Address not found in the list."
},
.
.
.
]
期望的输出:
[
{
"ID" : "1",
"Name" : "ABC",
"data-Quality-Rule" :
{
"field" : "ABC",
"field-Type": "String",
"operator": "Not-In-List" ,
"condition-Operand-Type": "",
"error-Message": "Name - Invalid Value: Name not found in the list."
}
},
{
"ID" : "1",
"Name" : "ABC",
"data-Quality-Rule" :
{
"field" : "ABC",
"field-Type": "String",
"operator": "invalid" ,
"condition-Operand-Type": "",
"error-Message": "Name - Invalid Value: There cannot be special char in a name."
}
},
{
"ID" : "1",
"Roll" : "123",
"data-Quality-Rule" :
{
"field" : "123",
"field-Type": "String",
"operator": "Not-In-List" ,
"condition-Operand-Type": "",
"error-Message": "Roll - Invalid Value: Roll not found in the list."
}
},
.
.
.
]
【问题讨论】: