
In terms of foundation, most YAML you'll encounter has a root mapping node. In this context, "root" means it's at the top-level (root level) of the file structure. "Mapping node" means it's a collection of data represented as a map. A map is composed of one or more unordered nodes of keys-values. The keys are separated from values by a colon and a space (:), like this example:
ExampleKey: ExampleValue
AnotherKey: AnotherValueThe equivalent in JSON is called an object.
{
"ExampleKey": "ExampleValue",
"AnotherKey": "AnotherValue"
}A map is a set of unordered key-value pairs:
Car: red
Hair: grayBecause maps are unordered key-value pairs, the previous map is the same as the following map:
Hair: gray
Car: redA map must have unique keys. The keys and values are case sensitive.
hair: gray
Hair: grayhair: gray
hair: grayMaps can be written in a more compact way with commas separating the map items.
{Hair: gray, Car: red}This is the same as normal map style.
Hair: gray
Car: redFlow maps are less common because they're more difficult to read.
The keys are separated by a colon and a space
If the space is missing, the YAML is broken.
Car:redTo fix it, add a space.
Car: redHair: gray
Car: red
Grass:green
Sky:blueSee answer
The Grass and Sky keys were missing a space after the colon.
The correct YAML is:
Hair: gray
Car: red
Grass: green
Sky: blueLooking ahead: The values (and keys) used in the example are all scalars (atomic data types). The next lesson is about scalars (the most common type of value).