In my Mule 4 flow I get a JSON Array similar to the following:
[
{
"type": "error",
"status": 404,
"code": "not_found",
"message": "Could not find the resource",
},
{
"type": "error",
"status": 401,
"code": "",
"message": "Could not find the specified ",
}
]
I want to change the value of the message
field to a vars.germanMessage
variable for each JSON object.
I've tried to modify it with Dataweave 2 this way:
%dw 2.0
output application/java
---
(payload as Array) map {
"message": vars.germanMessage
}
But this returns a new JSON message with only the message
field.
The input type is Array<Object>
and output type too.
Is there any way to replace the value without changing the rest of the message?