Inputs on converting Mule 3 expression to a Mule 4 expression

197 Views Asked by At

We are migrating a Mule 3 application to Mule 4 using the Mule Migration Assistant (MMA). While migrating encountered below code which can not be migrated automatically.

Any inputs on how to manually convert this to Mule 4?

Please note: Need only the syntax as we are not aware of the input or required output.

mel:appendix.get(propertyKey).get(payload.getValue()) != null ? payload.setValue(appendix.get(propertyKey).get(payload.getValue())) : payload.setValue(payload.getValue())
1

There are 1 best solutions below

0
aled On

I can't be sure this will work with whatever Java class payload has but a DataWeave equivalent could be:

%dw 2.0
output application/json
var propertyKey="key2"
var appendix={key1:{a: 10, b: 20, c: 30, d: 40}, key2: {a: 50, b: 60, c: 70, d: 80}}
---
payload update {
    case .value if (appendix[propertyKey][payload.value] != null) -> appendix[propertyKey][payload.value]
}