• Superset of JSON. No literal tab for indentation. The indentation level can be one or more spaces.
  • The difference between single quotes and double quotes is that in double quotes you can use escapes, i.e., \t, \n
  • YAML supports multiple documents, and compliant parsers will recognize each set of dashes as the beginning of a new one
  • YAML documents in a stream may be preceded by ‘directives’ composed of a percent sign (%) followed by a name and space-delimited parameters
  • Common to use JSON Schema to validate, e.g., patternProperties, additionalProperties, anyOf
--- # These dashes indicate the start of a new YAML document
key: value
boolean: true
single quotes: 'have ''one'' escape pattern'
# Notice that strings don't need to be quoted. However, they can be.
however: 'A string, enclosed in quotes.'
# Multiple-line strings can be written either as a 'literal block' (using |). This is particularly helpful when defining shell commands
# a 'folded block' (using '>'): all newlines will be replaced with a single space
literal_block: |
    This entire block of text will be the value of the 'literal_block' key,
    with line breaks being preserved.

    The literal continues until de-dented, and the leading indentation is
    stripped.

        Any lines that are 'more-indented' keep the rest of their indentation -
        these lines will be indented by 4 spaces.
# Sequences (equivalent to lists or arrays) look like this
# (note that the '-' counts as indentation):
a_sequence:
  - Item 1
  - Item 2
  - 0.5  # sequences can contain disparate types.
  - Item 4
  - key: value
    another_key: another_value
  -
    - This is a sequence
    - inside another sequence
  - - - Nested sequence indicators
      - can be collapsed
# Since YAML is a superset of JSON, you can also write JSON-style maps and
# sequences:
json_map: {"key": "value"}
json_seq: [3, 2, 1, "takeoff"]

# YAML also has a handy feature called 'anchors', which let you easily duplicate
# content across your document. Both of these keys will have the same value:
anchored_content: &anchor_name This string will appear as the value of two keys.
other_anchor: *anchor_name

# Anchors can be used to duplicate/inherit properties
base: &base
  name: Everyone has same name

# The regexp << is called Merge Key Language-Independent Type. It is used to
# indicate that all the keys of one or more specified maps should be inserted
# into the current map.
foo:
  <<: *base
  age: 10

# Strings and numbers aren't the only scalars that YAML can understand.
# ISO-formatted date and datetime literals are also parsed.
datetime: 2001-12-15T02:59:43.1Z
datetime_with_spaces: 2001-12-14 21:59:43.10 -5
date: 2002-12-14

# enforce a newline to be kept
fold_some_newlines: >
    a
    b

    c
    d
      e
    f


# enter nulls with a tilde or the unquoted null string literal.
foo: ~
bar: null

#To save the last character, add a plus to the fold or block operators.
#  if the value ends with whitespace, like a newline, YAML will preserve it. To strip the character, use the strip operator.,i.e., - instead of +
bar: >+
  this is not a normal string it
  spans more than
  one line
  see?

d: !!float 123             # also a float via explicit data type prefixed by (!!)
e: !!str 123               # a string, disambiguated by explicit type
f: !!str Yes               # a string via explicit type