The most recent YAML specification (you link to something replaced 9 years ago) states:
Application specific tag resolution rules should be restricted to resolving the “?” non-specific tag, most commonly to resolving plain scalars. These may be matched against a set of regular expressions to provide automatic resolution of integers, floats, timestamps, and similar types.
A boolean is one of these "similar types". So True
would be interpreted as a boolean and "True"
or 'True'
(because these are not plain scalars) as strings.
In the outdated YAML 1.1 specification Yes
and On
(and their opposites, and all of these in all-caps, all-lowercase) were also interpreted as booleans, but this notion was dropped from the 1.2 specification.
So you want to represent the string "Yes" (without the quotes) as a value, and if you are sure your data will be read by a parser updated after 2009, then you can use a plain scalar, single quotes, double quotes or, e.g. a block style literal scalar (assuming a sequence with single key/value mappings, with key [1, 2]
):
- [1, 2]: Yes
- [1, 2]: 'Yes'
- [1, 2]: "Yes"
- [1, 2]: |
Yes
All but the first will also work with a parser that only supports the YAML 1.1 standard. You can of course make sure that later processing "knows" about what you expect by explicitly starting your document with the YAML directive and the end-of-directive indicator
%YAML 1.2
---