Course
Dataweave
73 lessons154 min total
-
What is Dataweave
DataWeave is a programming language designed for transforming data. It is MuleSoft’s primary language for data transformation, as…
-
MIME TYPES in DataWeave 2.0
DataWeave can read and write many types of data formats, such as JSON, XML, CSV, XSLS and many…
-
AVRO FORMAT
Avro is a row-based storage format for Hadoop, which is widely used as a serialization platform.
-
CSV FILE FORMAT
A comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. Each…
-
DataWeave Format
The DataWeave (dw) format is the canonical format for all transformations. This format can help you understand how…
-
Flat File Format
A flat-file database is a database stored in a file called a flat file. Records follow a uniform…
-
JAVA Format
The java string format() method returns the formatted string by given locale, format and arguments. If you don't…
-
Json Format
JSON (JavaScript Object Notation, pronounced /ˈdʒeɪsən/; also /ˈdʒeɪˌsɒn/) is an open standard file format and data interchange format…
-
Binary Format
Binary format means that the sign (positive or negative) is in the leftmost bit of the field and…
-
Excel Format
When we format cells in Excel, we change the appearance of a number without changing the number itself.…
-
XML Format
The Extensible Markup Language (XML) is a simple text-based format for representing structured information: documents, data, configuration, books,…
-
Newline Delimited json Format
NDJSON is a convenient format for storing or streaming structured data that may be processed one record at…
-
URL Encoded Format
URL encoding converts non-ASCII characters into a format that can be transmitted over the Internet. URL encoding replaces…
-
YAML Format
YAML is a data serialization language that is often used for writing configuration files. Depending on whom you…
-
Multipart Format (Form Data)
DataWeave supports Multipart subtypes, in particular form-data. These formats enable you to handle several different data parts in…
-
Text Plain Format
The simplest way to store information in computer memory is as a single file with a plain text…
-
Text Java Properties Format
The Text Java Properties format parses any Java properties file. This format represents simple key-value pairs. DataWeave represents…
-
SCRIPT ANATOMY
Notice in the script that there are three lines, a line with three dashes, then one more line.…
-
Creating Data
As you'd expect, the last two are actually composite types, their contents also have type definitions:
-
Reading Data
reading data is just as important, and the features available to do so are just as robust.
-
Single-Value Selector
The single-value selector (.) allows you to lookup Object values by their key.
-
Multi-Value Selector (.*)
The multi-value selector (.*) returns an Array containing any value that matches the key. The values returned are…
-
Descendants Selector (..)
The descendants selector (..) is the perfect tool to use when you need the values for a certain…
-
Key-Value Pair Selector (.&myKey)
The & selector acts on arrays and objects. & retrieves both the keys and values of all matching…
-
Index Selector ([])
The index selector returns the element at the specified position. It can be applied over an array, object,…
-
Range selector (anIndex to anotherIndex)
If you need multiple sequential values from an Array, DataWeave allows you to select a range of values…
-
XML Attribute Selector (.@myKey)
Using .@ without the key name returns an object containing the attributes as key-value pairs.
-
Namespace Selector (#)
# returns the XML namespace of a selected key as plain text.
-
Selector Modifiers (!, ?)
You can check for the presence of a given key. ! evaluates the selection and fails with an…
-
Filter Selectors (myKey[?($ == “aValue”)])
myKey[?($ == "aValue")] returns only the values of matching keys within an array or object. Note that ?…
-
Metadata Selector (.^someMetadata)
Returns the value of specified metadata for a Mule payload, variable, or attribute.
-
Content Length Metadata Selector (.^contentLength)
In the following Mule app flow, the Logger uses payload.^contentLength to select the length of the string my…
-
Class Metadata Selector (.^class)
Returns the class of the Plain Old Java Object (POJO). The value might result from calling a method…
-
Encoding Metadata Selector (.^encoding)
In the following Mule app flow, the Logger uses payload.^encoding to select the encoding of "my string"`set in…
-
Media Type Metadata Selector (.^mediaType)
Returns the MIME type of a value that includes parameters (for example, application/json;charset=UTF-16). The expression in the value…
-
MIME Type Metadata Selector (.^mimeType)
In the following Mule app flow, the Loggers use payload.^mimeType to select a string "my string", then to…
-
Raw Metadata Selector (.^raw)
The following example uses the Set Payload component (set-payload) to produce a binary value, then uses the Transform…
-
Custom Metadata Selector (.^myCustomMetadata)
The following example uses userName.^myCustomMetadata to return the value of custom metadata that is defined as a variable…
-
Scatter-Gather Router
The Scatter-Gather component is a routing event processor that processes a Mule event through different parallel processing routes…
-
Error Handling in Mule 4
An exception occurs when an unexpected event happens while processing. Exception (or error) handling is the process of…
-
Variables in DataWeave 2.0 (Mule 4)
Variables are a way to store values with a given name so they can be later reused from…
-
Global & Local Variables In DataWeave 2.0
We can create a global variable in the header using var directive. We need to give it a…
-
Logical Operators
A logical operator is a symbol or word used to connect two or more expressions such that the…
-
Flow Control
Flow control is used when you want to execute certain parts of your code in some situations, while…
-
if else Condition in Flow Control (DataWeave 2.0)
An if statement evaluates a conditional expression and returns the value under the if only if the conditional…
-
else if Condition in flow (DataWeave 2.0)
You can chain several else expressions together within an if-else construct by incorporating else if.
-
do statement in flow control (DataWeave 2.0)
A do statement creates a scope in which new variables, functions, annotations, or namespaces can be declared and…
-
Pattern Matching with Literal Values
A match expression contains a list of case statements that can optionally have an else statement. Each case…
-
Functions in DataWeave 2.0
You can define your own DataWeave functions using the fun declaration in the header of a DataWeave script.
-
Named Functions
We create functions in the declarations section of the script using the fun keyword. This associates a set…
-
Lambdas Function
DataWeave provides multiple ways to create functions. Just like we have named functions, we have functions without names,…
-
Functions as Values
In other words, lambdas become useful when you want to pass functions as arguments to other functions, or…
-
Infix Notation
This type of notation is referred to as infix since the operator is in between the two operands…
-
$, $$, $$$ Syntax
For functions that DataWeave provides, you can represent the first, second, and third arguments of the passed lambda…
-
Arrays (dw::core::Arrays)
DataWeave 2.0 makes it easier to define an array with a range (" to ").
-
The filter Function (and Function Type Signatures) In DataWeave Mule 4
This function can be applied to an array. It iterates the array and matches the values with the…
-
The map Function In DataWeave Mule 4
Iterates over items in an array and outputs the results into a new array.
-
The distinctBy Function In DataWeave Mule 4
This function is useful for when you need to remove duplicate items from an Array.
-
The groupBy Function In DataWeave Mule 4
This function is useful for grouping together items in an array based on some value that is generated…
-
The reduce Function In DataWeave Mule 4
Reduce function is used to do any computation while iterating on an array, so the computation result is…
-
Working with Objects
It processes both keys and values as a tuple.
-
filterObject function in DataWeave 2.0 (mulesoft)
The filterObjectoperator iterates over a list of key-value pairs in an object and applies an expression that returns…
-
mapObject function in DataWeave 2.0 (mulesoft)
We use mapObject when we want to change the keys and/or values on an Object to be something…
-
pluck function in DataWeave 2.0 (mulesoft)
The pluck operator is useful for mapping the object into the array, and it returns the array of…
-
Update Operator
This operator is the one to use when you wish to change specific fields on an Object, while…
-
Update Operator Examples
Update Operator Examples
-
Selector Expressions (update Operator)
Use selector expressions with the update operator to specify the fields to update.
-
flatten function in DataWeave 2.0 (mulesoft)
With the help of flatten function multiple arrays are bounded together as single array.
-
splitBy function in DataWeave 2.0 (mulesoft)
Splits a string into a string array based on a value of input or matches part of that…
-
splitBy Examples in DataWeave 2.0
Helper function that enables splitBy to work with a null value.
-
read function in DataWeave
Reads a string or binary and returns parsed content. This function can be useful if the reader cannot…
-
readUrl in DataWeave
ThereadUrlfunction is similar to the read function, but it accepts URL as an input and the remaining parameters…
-
readUrl Example in DataWeave
readUrl Example