根据Mule 3中的条件从数组中删除对象



我想从列表中删除配置文件为Aftersales_Manager的对象和raflag是错误的,但我在Mule 3的DataWeave 1.0中面临和问题。请建议Mule 3中正确的DataWeave代码。

%dw 1.0
%output application/json
---
payload filter ($.raflag != false and $.mule_temp_profile ='Aftersales_Manager') 
map {
"ldap": $.ldap,
"status": $.status,
"m_value": $.m_value,
"raflag": $.raflag,
"profile": $.profile
}

输入:

[{
"ldap": "V00075",
"raflag": true,
"profile": "Aftersales_Manager"
}, {
"ldap": "V00076",
"raflag": true,
"profile": "Aftersales_Manager"
}, {
"ldap": "V00077",
"raflag": false,
"profile": "Aftersales_Manager"
}, {
"ldap": "V00078",
"raflag": true,
"profile": "Worker"
}, {
"ldap": "V00079",
"raflag": true,
"profile": "Manager"
}]

预期输出:

[{
"ldap": "V00075",
"raflag": true,
"profile": "Aftersales_Manager"
},
{
"ldap": "V00076",
"raflag": true,
"profile": "Aftersales_Manager"
},
{
"ldap": "V00078",
"raflag": true,
"profile": "Worker"
},
{
"ldap": "V00079",
"raflag": true,
"profile": "Manager"
}
]

您的输入没有mule_temp_profile。我猜你指的是profile。没有必要将raflag与false进行比较,因为它已经是一个布尔值。映射也是不需要的,因为毕竟输出的是相同的键值。

%dw 1.0
%output application/json
---
payload filter ($.raflag or $.profile !='Aftersales_Manager') 

输出:

[
{
"ldap": "V00075",
"raflag": true,
"profile": "Aftersales_Manager"
},
{
"ldap": "V00076",
"raflag": true,
"profile": "Aftersales_Manager"
},
{
"ldap": "V00078",
"raflag": true,
"profile": "Worker"
},
{
"ldap": "V00079",
"raflag": true,
"profile": "Manager"
}
]

相关内容

  • 没有找到相关文章

最新更新