Skip to main content

YAML Sparse Sequences

YAML Sparse Sequences

YAML Sparse Sequences are sequences (usually large sequences) that may contain only a small number of non-null entries

YAML allows to serialize such sequences using the mapping style with an explicit sequence type family.

note

The only supported keys are integers, serving as zero-based sequence entry indices.

For example:

Sparse Sequence
my-sequence: !seq
2: Third entry
4: ~

That is converted into an an identical in-memory sequence, which has a seperate identity:

Coverted Sparse Sequence
my-sequence:
- ~
- ~
- Third entry
- ~
- ~
note

Note that it is possible to serialize such sparse sequences using the null implicit type family but it is awkward!

Table of Contents