I wrote this article as part of my YAML::PP Grant report for December 2017.
This article will give you an overview how a YAML document is loaded into
a data structure and how a processor decides if something is a string, a
number, a boolean or something else.
If you look at JSON, the rules are quite obvious:
{
"string": "just a string",
"boolean": true,
"integer": 42,
"float": 3.14159,
"undefined": null,
"list": [1, 2, 3]
}
In YAML, it depends on the YAML version, and on the Schema the Processor
implements. This makes it more powerful, but also more complicated to
implement and use.
Some processors implement YAML 1.1, some implement 1.2, and often there
are things that aren't implemented correctly. When writing YAML, it's good
to know the official specification to understand why some things are supported
in one processor, but not in others.
This article covers:
- Standard Tags/Schema in YAML 1.2
- Type System in YAML 1.1
- How to write compatible YAML
- Other types of Schemas
As an example, note how boolean handling differs in YAML 1.1/1.2 and the 1.2
schemas.