Skip to content
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 string

Explanation

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