Like JSON, but more human-readable.
YAML is a space-dependent Data Serialization method, that extends upon JSON. It is highly flexible and has many features JDD AS IN lacks, but is more confusing to learn and also subject to type-inferencing errors if you’re not paying attention.
A JSON string is also valid YAML, but a YAML string is probably not valid JSON.
YAML is a way to provide metadata to a Markdown file & is used for coding configuration files. It can be used for general data storage. See also: YAML Uses
There’s a good NodeJS package that allows you to read/write to YAML using JavaScript. Can convert 1:1 to JSON.
Fast Facts
- Uses whitespace indentation (but not tabs)
- Can store multiple documents within a single file
- Comments start with #
- Lists can be done in two ways:
- [item 1, item 2] (like JSON)
- Or one per line, with the line starting with a hyphen
- Associative arrays (like Objects in JavaScript) can be done two ways:
- {key: value} (like JSON)
- with simple key, colon, space, value
- Strings typically aren’t quoted, but can also be quoted or double-quoted
- Can have references and tags, using an Ampersand Sigil to denote the tag location and an asterisk sigil to reference it
- The use of references allows for Graphs to be represented in YAML (not just trees, like JSON)