What is Indentation in YAML?

Category: YAMLWhat is Indentation in YAML?
Editor">Editor Staff asked 2 years ago

What is Indentation in YAML?

1 Answers
Editor">Editor Staff answered 2 years ago

Structure is determined by the indentation (line break character followed by zero or more spaces at start of the line).

  • Tab characters are not allowed in indentation as they vary in different system.
  • The amount of indentation is presentation detail.
  • The child node is more indentated than parent node.
  • All sibilings should follow same indentation and content of sibilings can be indented independently.
  • The “-”, “?” and “:” characters used to denote block collection entries.

Example:
%YAML 1.2- – -!!map {  ? !!str “Not indented”  : !!map {      ? !!str “By one space”      : !!str “By four\n  spaces\n”,      ? !!str “Flow style”      : !!seq [          !!str “By two”,          !!str “Also by two”,          !!str “Still by two”,        ]    }}