YAML Structure
YAML Structure
In YAML, there can be multiple directives or documents in a single file.
The separation of documents in YAML is made with three dashes (---
) and the end of document is marked with three dots (...
).
For example:
# Tom
---
first_name: Tom
last_name: Nolan
hair_color: Black
married: true
spouse:
name: Greta
occupation: Doctor
interests:
- Gardening
- Instagram
# Luke
---
first_name: Luke
last_name: Smith
hair_color: Brown
married: false
...
note
When we add three dots (...
) in place of three dashes, these three dots will provide the signal about the end of this directive or this entire collection by closing the data stream.
note
Three dashes ---
and three dots ...
are needed if you want to insert multiple documents in the same stream.
Most of the YAML configuration files you will encounter will have a single document for each stream, so dashes and dots are entirely optional in these cases.