YAML
Schema Types
How YAML 1.1 and 1.2 resolve scalars.
By EZ4Code Team
schemaresolutiontypes
Code
# These resolve differently across schemas
yes: yes # 1.1: bool true | 1.2: string "yes"
no: no # 1.1: bool false | 1.2: string "no"
version: 1.0 # float 1.0
count: 010 # 1.1: octal 8 | 1.2: string "010"
flag: on # 1.1: bool true | 1.2: string "on"
sex: m # string
explicit: !!str yes # always stringExplanation
YAML 1.1 treats yes/no/on/off as booleans and leading-zero numbers as octal, which causes surprising data loss. YAML 1.2 (the Failsafe/JSON/Core schemas) restricts booleans to true/false and removes octal guessing. When portability matters, quote ambiguous scalars or pin a schema explicitly.
More YAML Snippets
Scalars
Strings, numbers, booleans, null, and dates.
Sequences and Mappings
Lists and key-value maps.
Anchors and Aliases
Reuse nodes with anchors, aliases, and merge keys.
Multi-Document
Several documents in one stream.
Tags
Explicit type tags for custom resolution.
Flow Style
Inline JSON-like sequences and mappings.