Categories: Dataweave

MIME TYPES in DataWeave 2.0

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/avroavroAvro Format
application/csvcsvCSV Format
application/dwdwDataWeave Format (dw) for testing a DataWeave expression
application/flatfileflatfileFlat File Format, COBOL Copybook Format, Fixed Width Format
application/javajavaJava Format, Enum Format for Java
application/jsonjsonJSON Format
application/octet-streambinaryBinary Format
application/xlsxexcelExcel Format
application/xmlxmlXML Format, CData Custom Type
application/x-ndjsonndjsonNewline Delimited JSON Format (ndjson)
application/x-www-form-urlencodedurlencodedURL Encoded Format
application/yamlyamlYAML Format
multipart/form-datamultipartMultipart Format
text/plaintextText Plain Format
text/x-java-propertiespropertiesText 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.

  • Indexed: Uses indexes over the disk. DataWeave can only read the following formats in the indexed mode: CSV, JSON, XML (starting in Mule 4.3.0)

    Note that DataWeave does not support reading Excel (XLSX) input in the indexed mode.
  • In-Memory: Parses the entire document in memory.


    DataWeave can read all supported formats using the in-memory mode.
  • Streaming: Allows for sequential access to the file. This strategy partitions the input document into smaller items and accesses its data sequentially, storing the current item in memory. A DataWeave selector can access the portion of the file that is getting read.

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)

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

Instagram

Facebook

Recent Posts

Generate Parenthesis | Intuition + Code | Recursion Tree | Backtracking | Java

Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…

3 months ago

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

2 years ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

2 years ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

2 years ago