Script structure
DataWeave reference and playground
We won’t be covering a detailed breakdown of the DataWeave language in this book. If you want to learn more about DataWeave, MuleSoft provides a DataWeave playground at https://dataweave.mulesoft.com/learn/playground, which you can use to see how data can be transformed and manipulated by DataWeave functions. MuleSoft also has a detailed language guide, the current version of which can be found at https://docs.mulesoft.com/dataweave/2.4/dataweave-language-guide.
A DataWeave script is a file that’s structured in the following way:
- A header detailing the DataWeave version to use, the data type of the input for the script (for example,
application/json
), the type of data to output from the script (for example,application/xml
), and, optionally, any additional imports, constants, or function definitions - A delimiter,
---
- The script body or payload to perform the transformation
For example, say...