Contact Us 1-800-596-4880

YAML Format

MIME Type: application/yaml

ID: yaml

Values in the YAML data format map one-to-one with DataWeave values. DataWeave natively supports all of the following YAML types:

  • String

  • Boolean

  • Number

  • Nil

  • Mapping

  • Sequences

Example: Represent YAML in the DataWeave Format (dw)

This example shows how DataWeave represents YAML values.

Input

The following YAML snippet serves as the input payload for the DataWeave source in this example.

american:
  - Boston Red Sox
  - Detroit Tigers
  - New York Yankees
national:
  - New York Mets
  - Chicago Cubs
  - Atlanta Braves

Source

The DataWeave script transforms the YAML encoded input payload to the DataWeave (dw) format and MIME type.

%dw 2.0
output application/dw
---
payload

Output

The following output shows how the YAML input is represented in the DataWeave (dw) format.

{
  "american": [
    "Boston Red Sox",
    "Detroit Tigers",
    "New York Yankees"
  ],
  "national": [
    "New York Mets",
    "Chicago Cubs",
    "Atlanta Braves"
  ]
}

Configuration Properties

DataWeave supports the following configuration properties for the YAML format.

Reader Properties

The YAML format accepts properties that provide instructions for reading input data.

Parameter Type Default Description

maxEntityCount

Number

1

The maximum number of entity expansions. The limit is provided to avoid the billion laughs attack, a denial-of-service attack.

Writer Properties

The YAML format accepts properties that provide instructions for writing output data.

Parameter Type Default Description

bufferSize

Number

8192

Size of the writer buffer.

deferred

Boolean

false

When set to true, DataWeave generates the output as a data stream, and the script’s execution is deferred until it is consumed. Valid values are true or false.

encoding

String

UTF-8

Encoding for the writer to use.

skipNullOn

String

null

Skips null values in the specified data structure. Valid values are arrays, objects, or everywhere. The writer does not skip such values unless you set the property.

Supported MIME Types

The YAML format supports the following MIME types.

MIME Type

application/yaml

text/yaml

application/x-yaml

text/x-yaml