How can i apply the filter to remove empty array while doing transformation. I tried to apply sizeOf ($) != 0 but that is not working. I am able to do this by creating function but here i have to remove while doing map.kindly suggest solution for that.
%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
})
})
})
}
}
Response from the dwl:
{
"EMIComputations": {
"eMIComputation": [{
"source": "EMI_IMP",
"loanData": [{
"customerGender": "F",
},
{
"customerGender": "M",
}
]
},
{
},
{
}
]
}
}
expected output:
"EMIComputations": {
"eMIComputation": [{
"source": "EMI_IMP",
"loanData": [{
"customerGender": "M",
},
{
"customerGender": "M",
}
]
}
]
}
}
(sizeOf $) != 0and try again.(filterEmpty(payload)) map .... There is not way to automate it, if that is what you are asking for.