DataWeave (MuleSoft)
DataWeave
How to
String to Binary
var keyBytes = "abcdefgh" as Binary
Payload as Binary
var payloadBinary = payload.^raw
Functions
Outer brackets {( ... )}
interpretation:
- {} are defining object
- () are transforming each element in the array as key/value pair. This is required for XML output data format. The meaning of it is a bit confusing.
Input:
[
{"firstname":"Alex", "lastname":"Andropov"},
{"firstname":"Bob", "lastname":"Tupolev"}
]
Transform:
users: {(payload map (object,index) -> {
first: object.firstname,
last: object.lastname
})}
Result:
<users>
<first>Alex</first>
<last>Andropov</first>
<first>Bob></first>
<last>Tupolev</last>
</users>