DataWeave Format

MIME type: application/dw

ID: dw

The DataWeave (dw) format is the canonical format for all transformations. This format can help you understand how input data is interpreted before it is transformed to a new format.

Note

This format is intended to help you debug the results of DataWeave transformations. It is significantly slower than other formats. It is not recommended to be used in production applications because it can impact the performance.

Example: Express XML in the DataWeave (dw) Format

The following example shows how to transform XML input to the DataWeave (dw) format.

Input

The example uses the following XML snippet as input.

<employees>

<employee>

<firstname>Mariano</firstname>

<lastname>DeAchaval</lastname>

</employee>

<employee>

<firstname>Leandro</firstname>

<lastname>Shokida</lastname>

</employee>

</employees>

Output

Output: in DataWeave Format

{

employees: {

employee: {

firstname: “Mariano”,

lastname: “DeAchaval”

},

employee: {

firstname: “Leandro”,

lastname: “Shokida”

}

}

} as Object {encoding: “UTF-8”, mimeType: “text/xml”}

Configuration Properties

DataWeave supports the following configuration properties for this format.

Reader Properties

This format accepts properties that provide instructions for reading input data.

ParameterTypeDefaultDescription
externalResourcesBooleanfalseEnables the readUrl to read external entities.Valid values are true or false.
javaModuleBooleanfalseEnables Java module functions to load.Valid values are true or false.
onlyDataBooleanfalseHandles only data and not other types of content, such as functions, when set to true. The DataWeave parser runs faster in the onlyData mode.Valid values are true or false.
privilegesStringAccepts a comma-separated list of privileges to use in the format, such as ‘Resources,Properties’.

Writer Properties

This format accepts properties that provide instructions for writing output data.

ParameterTypeDefaultDescription
bufferSizeNumber8192Size of the buffer writer.
deferredBooleanfalseGenerates the output as a data stream when set to true, and defers the script’s execution until consumed.Valid values are true or false.
ignoreSchemaBooleanfalseIgnores the schema when set to true.Valid values are true or false.
indentString‘ ‘String to use for indenting.
maxCollectionSizeNumber-1Maximum number of elements allowed in an array or an object. -1 indicates no limitation.
onlyDataBooleantrueHandles only data and not other types of content, such as functions, when set to true. The DataWeave parser runs faster in the onlyData mode.Valid values are true or false.

Supported MIME Types

This format supports the following MIME types.

MIME Type
*/dw

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