根据 Mule 3 中的条件从数组中删除对象
Remove objects from array based on conditions in 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 进行比较,因为它已经是一个布尔值。该地图也不需要,因为您毕竟输出相同的 key-values。
%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"
}
]
我想从列表中删除配置文件为 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 进行比较,因为它已经是一个布尔值。该地图也不需要,因为您毕竟输出相同的 key-values。
%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"
}
]