YAML notes
Concepts
Indentation
- YAML relies on indentation to define nesting levels. Increased indentation indicates a nested element within a list or dictionary.
- Consistent spacing (typically 2 or 4 spaces) is crucial, and mixing tabs and spaces is not allowed.
Lists
- Represented by a hyphen (
-
) followed by a space at the beginning of each line in the list. - Order matters in lists, the first element is accessed first
Key-Value Pairs (Mappings)
- Defined with a colon (
:
) separating the key and value. - Keys are unique identifiers within a mapping (dictionary-like structure).
- Order generally doesn't matter in mappings.
Folding and Literal Scalars
- YAML allows folding long strings (using the
>
character) to keep the code readable. - Literal scalars (using
|
character) preserve newlines and whitespace within the string value.
Advanced Techniques
- YAML anchors (denoted by
&
) and aliases (denoted by *
) allow referencing and reusing complex data structures within the YAML document. - While YAML doesn't have arithmetic or comparison operators, it offers these core mechanisms for building and managing data structures.
Data serialization language comparision