What is a YAML file?
YAML is a human-friendly data format that uses indentation for structure. It is a superset of JSON and is common for configuration files, CI pipelines and Kubernetes manifests.
Its flexibility is its trap. Unquoted NO is a boolean in YAML 1.1 but a string in 1.2, 0123 may be an octal number, and an alias only works inside the document that defines its anchor.
Anatomy of a YAML file
---Starts a document; a file may hold severalkey: valueA mapping entry, nested by indentation- itemA sequence entry| and >Literal and folded multi-line strings&owner / *ownerAn anchor and an alias to it# commentRuns to the end of the line
What you can generate
- Literal (|) and folded (>-) multi-line strings
- Anchors and aliases, defined again in each document
- The Norway problem: unquoted NO, yes, 0123 and 1.10
- Quoted specials: "null", "key: value", "a #b", "*not an alias"
- Several documents in one file
- Empty values, empty lists and maps
- Two- or four-space indentation
How to make one
- Open the YAML generator, or start from a preset above.
- Set the size and switch on the edge cases you need; the preview and size estimate follow every change.
- Generate, then download. The file is made in your browser, and the same preset and seed always give you the same file.
Questions
Yes. The tests parse every file with a YAML 1.2 parser and check the records.
In YAML 1.1 the unquoted country code NO means false. YAML 1.2 reads it as the string "NO". The file shows which rules your parser follows.
An anchor belongs to its own document, so an alias in the next document cannot see it. Each document defines it again, as the spec requires.