mule - 在 mule 3 中进行映射时从数组对象中删除空 json 数组
问题描述
如何在进行转换时应用过滤器来删除空数组。我试图应用 sizeOf ($) != 0 但这不起作用。我可以通过创建函数来做到这一点,但在这里我必须在执行 map.kindly 建议解决方案时删除。
%dw 1.0
%output application/json
---
{
employees: {
employee: (flowVars.varInputData.request.application.applicants) map ((applicant , indexOfApplicant) -> {
(flowVars.varMbResponse.application.applicants filter ($.customerID == applicant.customerID) map {
"source": "EMI_IMP",
"loanData": ($.customBureauResponse.customResponse.accountList map {
"customerGender": applicant.gender
})
})
})
}
}
来自 dwl 的回应:
{
"EMIComputations": {
"eMIComputation": [{
"source": "EMI_IMP",
"loanData": [{
"customerGender": "F",
},
{
"customerGender": "M",
}
]
},
{
},
{
}
]
}
}
预期输出:
"EMIComputations": {
"eMIComputation": [{
"source": "EMI_IMP",
"loanData": [{
"customerGender": "M",
},
{
"customerGender": "M",
}
]
}
]
}
}
解决方案
推荐阅读
- c# - 有条件地提供 ASP.NET Identity OAuth 令牌
- powerbi - 错误消息:R 脚本错误。错误:出现意外符号:“# Epilog - Auto Generated # setwd” 执行停止
- java - Hibernate 不会在 MySql 中自动创建数据库中不存在的表,但我没有收到任何错误
- correlation - 与数千个变量的相关性 - FDR
- javascript - 仅当从另一个选择元素列表中选择特定元素时才显示选择字段
- php - Codeigniter mysqli 问题
- git - 让 git 和 svn 在同一个文件夹上一起工作
- python - python - interpolation in pandas
- python - 将 Asyncio API 调用限制为 n 个同时会话 - 信号量不加载超过 1 个线程
- android - 直接从移动相机使用 FFmpeg 压缩视频