DataWeave (MuleSoft)

DataWeave

How to

String to Binary

var keyBytes = "abcdefgh" as Binary

Payload as Binary

var payloadBinary = payload.^raw

Functions

Outer brackets {( ... )} interpretation:

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>