变换消息中的条件 - m子



我想根据某种条件在mule应用中转换消息。

%dw 1.0
%output application/json
---
{
    **// create the below if the size of payload is greater than 0**
    resource_type : "speciality",
    speciality_name : payload[0].speciality_name,
    speciality_description : payload[0].speciality_description,
    uuid : payload[0].uuid
   **//else create the below message**
   message : "No records were fetched from backend"
}

任何人都可以帮助我吗?

您可以在此条件下使用。喜欢

%dw 1.0
%output application/json
---
{
    // create the below if the size of payload is greater than 0**
    resource_type : "speciality",
    speciality_name : payload[0].speciality_name,
    speciality_description : payload[0].speciality_description,
    uuid : payload[0].uuid
} when payload != null and (sizeOf payload) > 0 otherwise
{
   //else create the below message**
   message : "No records were fetched from backend"
}

希望这会有所帮助。

最新更新