...

/

Overview of advanced data types in YAML

Overview of advanced data types in YAML

Learn the advanced data types and how to represent them in YAML.

We'll cover the following...

Sequence (!!seq)

Sequence represents a collection indexed by sequential integers starting with zero as [0..n-1], where n is the number of items in the sequence.

It is specified by placing each member on a new line with a hyphen or dash character (-). See its usage in the example below.

Example

- red
- orange
- yellow

or

Example

# Ordered sequence of nodes
colors: !!seq
  - red
  - orange
  - yellow

There is also a compact notation using [] for sequence. The above sequence can also be represented as the example below:

Example

[red, orange, yellow]

The following is a graphical representation of the sequence in the code example:

code_drawing

Sparse sequence

A sequence where not all the keys have values is known as a sparse sequence. See the example below.

Example

sparse: 
  - red
  - ~
  - blue
  -
...