Writing DataWeave scripts
Now that we understand the basics of the DataWeave language, let’s start learning how to write DataWeave scripts. In this section, you’ll learn about operators, selectors, variables, functions, and scope and flow control. These will give you the basics so that you can start transforming your data.
Using operators
If you come from a different programming language background, you probably already know what operators are – those characters that help you transform or compare data. Let’s take a look at the different types of operators in DataWeave and their purpose.
Mathematical operators
These operators transform two values into one. They’re mostly used for numbers but they can also be used with other data types:
- Addition (+): This operator adds two values. It can be used to add date and time-related types and numbers or to append a new item to an array (for example,
1 +
2
). - Subtraction (-): This operator...