Skip to main content

YAML Sets

YAML Sets

YAML Set (!!set) is an unordered set of non-equal values.

note

Note that a set is an unordered collection of nodes such that no two nodes are equal.

note

YAML Sets are a kind of mapping, so the !!set tag may be given explicitly.

Alternatively, the application may choose to implicitly type mappings with all-null values to sets. In this case, an explicit !!map transfer must be given to mappings that have all-null values but do not represent sets.

For example:

baseball-players: !!set
? Tom Nolan
? Ryan Raynolds
? John Smith

Another example:

set1: !!set
? one
? two
set1: !!set
? three
? four
Equivalent JSON
{
"set1": {"one": null, "two": null},
"set2": {"three": null, "four": null}
}
note

You can also use the flow style to define a set

my-set: !!set {'one', "two"}

Table of Contents