Skip to main content

YAML Nested Sequences

YAML Nested Sequences

A YAML nested sequence is a sequence contained within another sequence.

For example:

person: 
-
name: Luke
hobbies:
- sports
- music
-
name: Ryan
hobbies:
- movies
- cooking
-
name: Thomas
hobbies:
- tennis
- swimming

note

Nested sequences can also be used to represent more complex data structures.

Another more complex example:

example:
id: 1
name: Tom
salary: 20000
hobby:
- Computer programming
- Tennis
location: {country: "Italy", city: "Rome"}
Equivalent JSON
{
"example": {
"id": 1,
"name": "Tom",
"salary": 20000,
"hobby": ["Computer programming", "Tennis"],
"location": {
"country": "Italy", "city": "Rome"
}
}
}

Table of Contents