Skip to content

YAML Sparse Sequences

Learn how YAML sparse sequences efficiently represent large sequences with mostly null entries using integer-indexed mappings and the !seq type family.

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.

For example:

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

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

Coverted Sparse Sequenceyaml
my-sequence:
 - ~
 - ~
 - Third entry
 - ~
 - ~
Navigation