YAML Indentation and Separation
Indentation and separation are two fundamental concepts for learning any programming language.
Indentation in YAML
YAML does not include mandatory spaces. Also, it is not necessary to be consistent.
An example of valid YAML indentation is shown below:
- Flow blocks must be have at least some spaces with surrounding current block level.
- Flow content of YAML spans multiple lines and the beginning of flow content is defined with
- Block list items include same indentation as the surrounding block level because
-is considered as a part of indentation.
date : 2022-05-20
name : Tom
surname : Nolan
458 Walkman Dr.
city : New York
state : NY
postal : 10001
- sku : BL321D
quantity : 2
description : Basketball
price : 150.00
- sku : BL1221H
quantity : 4
description : Super Shoes
price : 999.00
tax : 175.62
Early morning is best.
Backup contact is Liam.
Don't worry if you don't understand the meaning of all the symbols.
You will learn more in the next chapters!
String Separation in YAML
Strings are separated using double-quoted string.
If you escape the newline characters in a given string, it is completely removed and translated into space value.
An example of a list of animals:
Note that each item is listed with a prefix of hyphen.