YAML Sequence Style
YAML Sequence Style
YAML Sequences Styles are closely related to the concept of collections.
The collection in YAML is represented with proper sequence styles.
note
Collections in YAML are indexed by sequential integers starting with zero as represented in arrays.
warning
Sequence Style is a collections-specific style in which the block style or flow style is alternately used!
Example
The following code shows how to represent a sequence style, comparing block style and flow style:
# Ordered sequence of nodes in YAML STRUCTURE
Block style: !!seq
- Mercury # Comment.
- Venus # Comment.
- Earth # Comment.
- Mars # Comment.
- Jupiter # Comment.
- Saturn # Comment.
- Uranus # Comment.
- Neptune # Comment.
- Pluto # Comment?
Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Comment
Jupiter, Saturn, Uranus, Neptune, # Comment
Pluto ] # Comment
The JSON output of the given YAML is as follows:
{
"Flow style": [
"Mercury",
"Venus",
"Earth",
"Mars",
"Jupiter",
"Saturn",
"Uranus",
"Neptune",
"Pluto"
],
"Block style": [
"Mercury",
"Venus",
"Earth",
"Mars",
"Jupiter",
"Saturn",
"Uranus",
"Neptune",
"Pluto"
]
}
note
Note how Block Style and Flow Style are converted in the same JSON output.