YAML tutorial

YAML from the ground up: the basics and the features that make YAML a serialization language.

We also describe (some) of the dark corners only a conformant parser usually knows.

Every snippet on these pages is a file in the documentation’s examples, and every answer is go-yaml’s own output for it. go test checks each answer, so the pages cannot drift from the parser. The snippets and their examples are in docs/examples/tutorial.

  • JSON for humans: mappings, sequences, scalars and comments, each beside the JSON go-yaml reads from it.
  • Serialization experts: anchors, block scalars, documents, tags and explicit keys.
  • For machines, mostly: directives, merge keys, indentation indicators and tags beyond the standard ones.
  • YAML for conformant parsers only: legal documents that few humans read right.
  • YAML’s relatives and successors.