让我们说我从API调用中得到以下响应。
accounts: [
accountName: "A",
amount: 10$
account Name "B closed",
amount: 20$
]
我想过滤所有在帐户名称中包含close关键字的帐户响应。谁能告诉我如何基于此过滤包含已关闭的所有响应,并且仅给我帐户A。
我将dw 1.0用于我的mulesoft代码。如果您还有其他问题,请告诉我。
答案 0 :(得分:3)
假设您输入的是:
{
"accounts": [
{
"accountName": "A",
"amount": "10$"
},
{
"accountName": "B closed",
"amount": "20$"
}
]
}
然后您可以像这样过滤它:
%dw 1.0
%output application/json
---
payload.accounts filter ((account) -> not (account.accountName contains "closed"))
这将导致:
[
{
"accountName": "A",
"amount": "10$"
}
]