DataWeave can read and write many types of data formats, such as JSON, XML, CSV, XSLS and many others. Before you begin, note that DataWeave version 2 is for Mule 4 apps.
DataWeave supports the following formats as input and output:
application/avro | avro | Avro Format |
application/csv | csv | CSV Format |
application/dw | dw | DataWeave Format (dw) for testing a DataWeave expression |
application/flatfile | flatfile | Flat File Format, COBOL Copybook Format, Fixed Width Format |
application/java | java | Java Format, Enum Format for Java |
application/json | json | JSON Format |
application/octet-stream | binary | Binary Format |
application/xlsx | excel | Excel Format |
application/xml | xml | XML Format, CData Custom Type |
application/x-ndjson | ndjson | Newline Delimited JSON Format (ndjson) |
application/x-www-form-urlencoded | urlencoded | URL Encoded Format |
application/yaml | yaml | YAML Format |
multipart/form-data | multipart | Multipart Format |
text/plain | text | Text Plain Format |
text/x-java-properties | properties | Text Java Properties |
Note: Since DataWeave 2.3, MIME types can be specified with simple IDs such as json or xml. We will work with this syntax throughout this tutorial.
DataWeave Memory Management
DataWeave can read input data as a whole in-memory, in indexed fashion, and for some data formats, part-by-part by streaming the input.
When attempting to read a large file, it is possible to run out of memory or to impact performance negatively. Streaming can improve performance but impacts access to file.
Indexed and In-Memory:
Allow for random access to data because both strategies parse the entire document. When using these strategies, a DataWeave script can access any part of the resulting value at any time.
DataWeave supports streaming only for the following formats:
CSV, JSON, Excel (XLSX, starting in Mule 4.2.2), XML (starting in Mule 4.3.0)
If you like my post please follow me to read my latest post on programming and technology.
You are given a stream of elements that is too large to fit into memory.…
The formula for the area of a circle is given by πr². Use the Monte…
Given an integer k and a string s, write a function to determine the length…
There is a staircase with N steps, and you can ascend either 1 step or…
Build an autocomplete system that, given a query string s and a set of possible…
Design a job scheduler that accepts a function f and an integer n. The scheduler…