Search code examples
mulemule-componentdataweavemule-esb

How to check for empty array inside a payload ?


I am trying to have a choice condition where i will run a flow depending if array is empty.

Example :

Input : {"data":{"detailsSearch":[]}}

My code :

1. #[payload.data.detailsSearch*.size() > 0]
2. #[payload.data.detailsSearch*?]

I am getting an Runtime exception :

org.mule.api.MessagingException: Execution of the expression "payload.data.detailsSearch*.size() > 0" failed. (org.mule.api.expression.ExpressionRuntimeException).

I am looking for snippet to check for empty and null for this array


Solution

  • @Sandeep, you can try

    #[dw('sizeOf payload.data.detailsSearch')>0]