YamlSpecVersion Enum
Definition
Identifies the version of the YAML specification whose implicit type resolution the reader applies. The version controls how unquoted (plain) scalars are interpreted as booleans, null, and numbers.
public enum YamlSpecVersion
- Extension Methods
Fields
V1_2 = 0The YAML 1.2 core schema. Only
trueandfalseresolve to booleans, and an explicit tag is required to type tokens such asyesoroff.V1_1 = 1The YAML 1.1 schema. Additionally resolves
yes/no,on/off, andy/nas booleans, and accepts the YAML 1.1 integer forms (leading-zero octal, binary, and hexadecimal, each with an optional sign) and underscore digit grouping after the first digit. Base-60 ("sexagesimal") numbers are deliberately not resolved; a colon-separated scalar such as22:22stays a string.
Remarks
The default is V1_2, whose core schema resolves only true/false as booleans and
null/~/the empty scalar as null. This avoids the well-known "Norway problem" in which YAML 1.1
silently converts unquoted tokens such as no, yes, on, and off to booleans.
Selecting V1_1 opts in to the broader YAML 1.1 implicit typing rules, including the additional
boolean spellings (yes/no, on/off, y/n) and the YAML 1.1 int type's
integer forms: binary (0b1010), leading-zero octal (0755), decimal, and hexadecimal (0x1F).
Each integer form may carry a sign, so -0755 is -493 and -0x1F is -31, and may group its digits with
underscores after the first digit, so 1_000 is 1000 while _123 remains a string. The core schema's
0o octal form is also resolved, in the core schema's form, without a sign or digit groups. Floating-point
values group their digits with underscores too, but cannot begin with one or put one directly after a leading
decimal point, so _1.5 and ._5 remain strings. The base-60 ("sexagesimal") numeric form of the
historical 1.1 schema is deliberately not resolved under either version: a colon-separated plain scalar such as
22:22 remains a string, avoiding the well-known footgun in which time-, port-, or address-like values were
silently reinterpreted as large numbers. The version affects only how plain scalars are typed; structural parsing of
anchors, aliases, tags, and collections is identical for both versions.
Under either version, a floating-point literal beyond the range of a double, such as 1e309 or
-1e309, resolves to an infinity, as IEEE 754 conversion rounds it, rather than remaining a string; an
explicit !!float tag reads it the same way.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |