YAML - Study Notes
A singleline breakisfoldedinto a singlespace, whileempty linesare interpreted asline breakcharacters.
YAML can therefore be viewed as a natural superset of JSON, offering improved human readability and a more complete information model. This is also the case in practice; every JSON file is also a valid YAML file. This makes it easy to migrate from JSON to YAML if/when the additional features are required.
JSON'sRFC4627requires thatmappingskeysmerely “SHOULD” beunique, while YAML insists they “MUST” be. Technically, YAML therefore complies with the JSON spec, choosing to treat duplicates as an error. In practice, since JSON is silent on the semantics of such duplicates, the only portable JSON files are those with unique keys, which are therefore valid YAML files.
Block Style:
YAML’sblock collectionsuseindentationfor scope and begin each entry on its own line.Block sequencesindicate each entry with a dash and space(“-
”).Mappingsuse a colon and space(“:
”) to mark eachkey:value pair.Commentsbegin with an octothorpe (also called a “hash”, “sharp”, “pound”, or “number sign” -#
”).
Flow Style:
YAML also hasflow styles, using explicitindicatorsrather thanindentationto denote scope. Theflow sequenceis written as acommaseparated list withinsquarebrackets. In a similar manner, theflow mappingusescurlybraces.
Copied from:https://yaml.org/spec/1.2/spec.html