Reference: https://docs.mulesoft.com/mule-user-guide/v/3.9/dataweave
$$
: key / index
$
: value
@
: Create or reference XML attribute
%output application/dw
: Outputs the cannonical datamodel of DataWeave
Object:
{
key: "value"
}
Array:
%dw 1.0
%output application/json
---
[ "elem1", "elem2", "elem3" ]
Map operator:
%dw 1.0
%output application/json
---
shirts: payload map {
size: upper $.size,
description: $.description,
count: $.count
}
Constants and functions (%var):
%dw 1.0
%var prefix = 'The destination is: '
%var append = (param1, param2) -> param1 ++ param2
%var createFlightCodeElement = (code) -> flightCode: code
%var createDestinationCodeElement = (dest) -> destinationCode: dest
%output application/xml
---
flights: {(payload map {
flight @(flightCode: $.code):
{
destination: append(prefix, $.destination),
code: createFlightCodeElement($.code),
dest: createDestinationCodeElement($.destination)
}
})
}
XML attribute in output | ||
---|---|---|
Input | Transformation | Output |
|
|
|
Item index in the output ("$$") | ||
Input | Transformation | Output |
|
|
|