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

Minimum Cost to Paint Houses with K Colors

A builder plans to construct N houses in a row, where each house can be…

1 day ago

Longest Absolute Path in File System Representation

Find the length of the longest absolute path to a file within the abstracted file…

3 weeks ago

Efficient Order Log Storage

You manage an e-commerce website and need to keep track of the last N order…

1 month ago

Select a Random Element from a Stream

You are given a stream of elements that is too large to fit into memory.…

1 month ago

Estimate π Using Monte Carlo Method

The formula for the area of a circle is given by πr². Use the Monte…

2 months ago

Longest Substring with K Distinct Characters

Given an integer k and a string s, write a function to determine the length…

2 months ago