1

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())
aled
  • 21,330
  • 3
  • 27
  • 34
  • That won't work because MEL is basically a simplified Java interpreter while DataWeave is not. We would need to understand payload.setValue() and payload.getValue() to be able to suggest an alternative. – aled Feb 15 '22 at 19:54

1 Answers1

1

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]
}
aled
  • 21,330
  • 3
  • 27
  • 34