The Perl Module YAML::PP implements YAML 1.2.
You can choose between several Schemas.
The following table shows which strings result in which native data, depending
on the Schema (or other YAML module) you use.
For each of the Schemas and modules, the first column is the type,
and the second shows how the data is encoded into YAML again.
Note that the YAML 1.2 JSON Schema is not exactly like the official schema,
as all strings would have to be quoted.
YAML::PP | Other Perl Modules | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Input YAML | Failsafe | JSON | Core | YAML 1.1 | YAML.pm | YAML::Syck | YAML::XS | |||||||
Type | Output | Type | Output | Type | Output | Type | Output | Type | Output | Type | Output | Type | Output | |
null | str | null | null | null | null | null | null | str | null | ~ | null | ~ | ||
#empty | str | str | null | null | null | null | str | null | ~ | null | ~ | |||
NULL | str | str | null | null | null | null | str | null | ~ | str | ||||
Null | str | str | null | null | null | null | str | null | ~ | str | ||||
~ | str | str | null | null | null | null | null | ~ | null | ~ | null | ~ | ||
false | str | bool | false | bool | false | bool | false | str | float | '' | bool | false | ||
true | str | bool | true | bool | true | bool | true | str | float | 1 | bool | true | ||
FALSE | str | str | bool | false | bool | false | str | float | '' | str | ||||
False | str | str | bool | false | bool | false | str | float | '' | str | ||||
TRUE | str | str | bool | true | bool | true | str | float | 1 | str | ||||
True | str | str | bool | true | bool | true | str | float | 1 | str | ||||
N | str | str | str | bool | false | str | float | '' | str | |||||
n | str | str | str | bool | false | str | float | '' | str | |||||
NO | str | str | str | bool | false | str | float | '' | str | |||||
no | str | str | str | bool | false | str | float | '' | str | |||||
OFF | str | str | str | bool | false | str | float | '' | str | |||||
Off | str | str | str | bool | false | str | float | '' | str | |||||
off | str | str | str | bool | false | str | float | '' | str | |||||
ON | str | str | str | bool | true | str | float | 1 | str | |||||
On | str | str | str | bool | true | str | float | 1 | str | |||||
on | str | str | str | bool | true | str | float | 1 | str | |||||
Y | str | str | str | bool | true | str | float | 1 | str | |||||
y | str | str | str | bool | true | str | float | 1 | str | |||||
YES | str | str | str | bool | true | str | float | 1 | str | |||||
Yes | str | str | str | bool | true | str | float | 1 | str | |||||
yes | str | str | str | bool | true | str | float | 1 | str | |||||
-3.14 | str | float | -3.14 | float | -3.14 | float | -3.14 | float | -3.14 | float | '-3.14' | float | -3.14 | |
0.0 | str | float | 0.0 | float | 0.0 | float | 0.0 | float | 0 | float | '0' | float | 0.0 | |
3.14 | str | float | 3.14 | float | 3.14 | float | 3.14 | float | 3.14 | float | '3.14' | float | 3.14 | |
3.3e+3 | str | float | 3300.0 | float | 3300.0 | float | 3300.0 | int | 3300 | float | '3300' | float | 3.3e+3 | |
Input YAML | Failsafe | JSON | Core | YAML 1.1 | YAML.pm | YAML::Syck | YAML::XS | |||||||
+0.3e+3 | str | str | float | 300.0 | float | 300.0 | str | float | '300' | float | +0.3e+3 | |||
+3.14 | str | str | float | 3.14 | float | 3.14 | str | float | '3.14' | float | +3.14 | |||
.0 | str | str | float | 0.0 | float | 0.0 | float | 0 | str | float | .0 | |||
.14 | str | str | float | 0.14 | float | 0.14 | float | 0.14 | str | float | .14 | |||
.3e+3 | str | str | float | 300.0 | float | 300.0 | int | 300 | str | float | .3e+3 | |||
.3E-1 | str | str | float | 0.03 | float | 0.03 | float | 0.03 | str | float | .3E-1 | |||
001.23 | str | str | float | 1.23 | float | 1.23 | str | float | '1.23' | float | 001.23 | |||
190:20:30.15 | str | str | str | float | 685230.15 | str | float | '685230.15' | str | |||||
85.230_15e+03 | str | str | str | float | 85230.15 | str | str | str | ||||||
85_230.15 | str | str | str | float | 85230.15 | str | str | str | ||||||
+.INF | str | str | inf | .inf | inf | .inf | str | inf | 'Inf' | str | ||||
+.Inf | str | str | inf | .inf | inf | .inf | str | inf | 'Inf' | str | ||||
+.inf | str | str | inf | .inf | inf | .inf | str | inf | 'Inf' | str | ||||
-.INF | str | str | inf | -.inf | inf | -.inf | str | inf | '-Inf' | str | ||||
-.Inf | str | str | inf | -.inf | inf | -.inf | str | inf | '-Inf' | str | ||||
-.inf | str | str | inf | -.inf | inf | -.inf | str | inf | '-Inf' | str | ||||
.INF | str | str | inf | .inf | inf | .inf | str | inf | 'Inf' | str | ||||
.Inf | str | str | inf | .inf | inf | .inf | str | inf | 'Inf' | str | ||||
.inf | str | str | inf | .inf | inf | .inf | str | inf | 'Inf' | str | ||||
.NAN | str | str | nan | .nan | nan | .nan | str | nan | 'NaN' | str | ||||
.NaN | str | str | nan | .nan | nan | .nan | str | nan | 'NaN' | str | ||||
.nan | str | str | nan | .nan | nan | .nan | str | nan | 'NaN' | str | ||||
-0 | str | int | 0 | int | 0 | int | 0 | int | 0 | int | 0 | int | -0 | |
-23 | str | int | -23 | int | -23 | int | -23 | int | -23 | int | -23 | int | -23 | |
0 | str | int | 0 | int | 0 | int | 0 | int | 0 | int | 0 | int | 0 | |
23 | str | int | 23 | int | 23 | int | 23 | int | 23 | int | 23 | int | 23 | |
+0 | str | str | int | 0 | int | 0 | str | int | 0 | int | +0 | |||
+23 | str | str | int | 23 | int | 23 | str | int | 23 | int | +23 | |||
00 | str | str | int | 0 | int | 0 | str | int | 0 | int | 00 | |||
0011 | str | str | int | 11 | int | 9 | str | int | 9 | int | 0011 | |||
Input YAML | Failsafe | JSON | Core | YAML 1.1 | YAML.pm | YAML::Syck | YAML::XS | |||||||
010 | str | str | int | 10 | int | 8 | str | int | 8 | int | 010 | |||
07 | str | str | int | 7 | int | 7 | str | int | 7 | int | 07 | |||
0x0 | str | str | int | 0 | int | 0 | str | int | 0 | str | ||||
0x10 | str | str | int | 16 | int | 16 | str | int | 16 | str | ||||
0x42 | str | str | int | 66 | int | 66 | str | int | 66 | str | ||||
0xa | str | str | int | 10 | int | 10 | str | int | 10 | str | ||||
+0100_200 | str | str | str | int | 32896 | str | str | str | ||||||
+0b100 | str | str | str | int | 4 | str | str | str | ||||||
+190:20:30 | str | str | str | int | 685230 | str | int | 685230 | str | |||||
-0100_200 | str | str | str | int | -32896 | str | str | str | ||||||
-0b101 | str | str | str | int | -5 | str | str | str | ||||||
-0x30 | str | str | str | int | -48 | str | int | 0 | str | |||||
-190:20:30 | str | str | str | int | -685230 | str | int | '18446744073708868846' | str | |||||
02_0 | str | str | str | int | 16 | str | str | str | ||||||
0b0 | str | str | str | int | 0 | str | str | str | ||||||
0b100_101 | str | str | str | int | 37 | str | str | str | ||||||
0x2_0 | str | str | str | int | 32 | str | str | str | ||||||
100_000 | str | str | str | int | 100000 | str | str | str | ||||||
190:20:30 | str | str | str | int | 685230 | str | int | 685230 | str | |||||
0.3e3 | str | float | 300.0 | float | 300.0 | str | int | 300 | str | float | 0.3e3 | |||
3e3 | todo | float | 3000.0 | float | 3000.0 | str | int | 3000 | str | float | 3e3 | |||
+0.3e3 | str | str | float | 300.0 | str | str | str | float | +0.3e3 | |||||
.3e3 | str | str | float | 300.0 | str | int | 300 | str | float | .3e3 | ||||
08 | str | str | int | 8 | str | str | str | int | 08 | |||||
0o0 | str | str | int | 0 | str | str | str | str | ||||||
0o10 | str | str | int | 8 | str | str | str | str | ||||||
0o7 | str | str | int | 7 | str | str | str | str | ||||||
!!null null | todo | null | null | null | null | null | null | str | null | ~ | null | ~ | ||
!!null #empty | todo | todo | null | null | null | null | str | null | ~ | null | ~ | |||
!!null NULL | todo | todo | null | null | null | null | str | null | ~ | error | ||||
Input YAML | Failsafe | JSON | Core | YAML 1.1 | YAML.pm | YAML::Syck | YAML::XS | |||||||
!!null Null | todo | todo | null | null | null | null | str | null | ~ | error | ||||
!!null ~ | todo | todo | null | null | null | null | str | null | ~ | null | ~ | |||
!!bool false | todo | bool | false | bool | false | bool | false | str | str | error | ||||
!!bool true | todo | bool | true | bool | true | bool | true | str | str | error | ||||
!!bool FALSE | todo | todo | bool | false | bool | false | str | str | error | |||||
!!bool False | todo | todo | bool | false | bool | false | str | str | error | |||||
!!bool TRUE | todo | todo | bool | true | bool | true | str | str | error | |||||
!!bool True | todo | todo | bool | true | bool | true | str | str | error | |||||
!!bool N | todo | todo | todo | bool | false | str | str | error | ||||||
!!bool n | todo | todo | todo | bool | false | str | str | error | ||||||
!!bool NO | todo | todo | todo | bool | false | str | str | error | ||||||
!!bool no | todo | todo | todo | bool | false | str | str | error | ||||||
!!bool OFF | todo | todo | todo | bool | false | str | str | error | ||||||
!!bool Off | todo | todo | todo | bool | false | str | str | error | ||||||
!!bool off | todo | todo | todo | bool | false | str | str | error | ||||||
!!bool ON | todo | todo | todo | bool | true | str | str | error | ||||||
!!bool On | todo | todo | todo | bool | true | str | str | error | ||||||
!!bool on | todo | todo | todo | bool | true | str | str | error | ||||||
!!bool Y | todo | todo | todo | bool | true | str | str | error | ||||||
!!bool y | todo | todo | todo | bool | true | str | str | error | ||||||
!!bool YES | todo | todo | todo | bool | true | str | str | error | ||||||
!!bool Yes | todo | todo | todo | bool | true | str | str | error | ||||||
!!bool yes | todo | todo | todo | bool | true | str | str | error | ||||||
!!float -3.14 | todo | float | -3.14 | float | -3.14 | float | -3.14 | float | -3.14 | float | '-3.14' | float | -3.14 | |
!!float 0.0 | todo | float | 0.0 | float | 0.0 | float | 0.0 | float | 0 | float | '0' | float | 0.0 | |
!!float 3.14 | todo | float | 3.14 | float | 3.14 | float | 3.14 | float | 3.14 | float | '3.14' | float | 3.14 | |
!!float +0.3e+3 | todo | todo | float | 300.0 | float | 300.0 | str | float | '300' | float | +0.3e+3 | |||
!!float .0 | todo | todo | float | 0.0 | float | 0.0 | float | 0 | float | '0' | float | .0 | ||
!!float .3e+3 | todo | todo | float | 300.0 | float | 300.0 | int | 300 | float | '300' | float | .3e+3 | ||
!!float .3E-1 | todo | todo | float | 0.03 | float | 0.03 | float | 0.03 | float | '0.03' | float | .3E-1 | ||
Input YAML | Failsafe | JSON | Core | YAML 1.1 | YAML.pm | YAML::Syck | YAML::XS | |||||||
!!float 001.23 | todo | todo | float | 1.23 | float | 1.23 | str | float | '1.23' | float | 001.23 | |||
!!float 3.3e+3 | todo | todo | float | 3300.0 | float | 3300.0 | int | 3300 | float | '3300' | float | 3.3e+3 | ||
!!float 190:20:30.15 | todo | todo | todo | float | 685230.15 | str | float | '190' | error | |||||
!!float 85.230_15e+03 | todo | todo | todo | float | 85230.15 | str | float | '85.23' | error | |||||
!!float 85_230.15 | todo | todo | todo | float | 85230.15 | str | float | '85' | error | |||||
!!float +.INF | todo | todo | inf | .inf | inf | .inf | str | float | '0' | error | ||||
!!float +.Inf | todo | todo | inf | .inf | inf | .inf | str | float | '0' | error | ||||
!!float +.inf | todo | todo | inf | .inf | inf | .inf | str | float | '0' | error | ||||
!!float -.INF | todo | todo | inf | -.inf | inf | -.inf | str | float | '0' | error | ||||
!!float -.Inf | todo | todo | inf | -.inf | inf | -.inf | str | float | '0' | error | ||||
!!float -.inf | todo | todo | inf | -.inf | inf | -.inf | str | float | '0' | error | ||||
!!float .INF | todo | todo | inf | .inf | inf | .inf | str | float | '0' | error | ||||
!!float .Inf | todo | todo | inf | .inf | inf | .inf | str | float | '0' | error | ||||
!!float .inf | todo | todo | inf | .inf | inf | .inf | str | float | '0' | error | ||||
!!float .NAN | todo | todo | nan | .nan | nan | .nan | str | float | '0' | error | ||||
!!float .NaN | todo | todo | nan | .nan | nan | .nan | str | float | '0' | error | ||||
!!float .nan | todo | todo | nan | .nan | nan | .nan | str | float | '0' | error | ||||
!!int -0 | todo | int | 0 | int | 0 | int | 0 | int | 0 | int | 0 | int | -0 | |
!!int -23 | todo | int | -23 | int | -23 | int | -23 | int | -23 | int | -23 | int | -23 | |
!!int 0 | todo | int | 0 | int | 0 | int | 0 | int | 0 | int | 0 | int | 0 | |
!!int 23 | todo | int | 23 | int | 23 | int | 23 | int | 23 | int | 23 | int | 23 | |
!!int +0 | todo | todo | int | 0 | int | 0 | str | int | 0 | int | +0 | |||
!!int +23 | todo | todo | int | 23 | int | 23 | str | int | 23 | int | +23 | |||
!!int 0011 | todo | todo | int | 11 | int | 9 | str | int | 11 | int | 0011 | |||
!!int 07 | todo | todo | int | 7 | int | 7 | str | int | 7 | int | 07 | |||
!!int 0x0 | todo | todo | int | 0 | int | 0 | str | float | '0' | error | ||||
!!int 0x10 | todo | todo | int | 16 | int | 16 | str | float | '0' | error | ||||
!!int 0x42 | todo | todo | int | 66 | int | 66 | str | float | '0' | error | ||||
!!int 0xa | todo | todo | int | 10 | int | 10 | str | float | '0' | error | ||||
!!int +0100_200 | todo | todo | todo | int | 32896 | str | float | '100' | error | |||||
Input YAML | Failsafe | JSON | Core | YAML 1.1 | YAML.pm | YAML::Syck | YAML::XS | |||||||
!!int +0b100 | todo | todo | todo | int | 4 | str | float | '0' | error | |||||
!!int +190:20:30 | todo | todo | todo | int | 685230 | str | float | '190' | error | |||||
!!int -0100_200 | todo | todo | todo | int | -32896 | str | float | '-100' | error | |||||
!!int -0b101 | todo | todo | todo | int | -5 | str | float | '0' | error | |||||
!!int -0x30 | todo | todo | todo | int | -48 | str | float | '0' | error | |||||
!!int -190:20:30 | todo | todo | todo | int | -685230 | str | float | '-190' | error | |||||
!!int 00 | todo | todo | todo | int | 0 | str | int | 0 | int | 00 | ||||
!!int 010 | todo | todo | todo | int | 8 | str | int | 10 | int | 010 | ||||
!!int 02_0 | todo | todo | todo | int | 16 | str | float | '2' | error | |||||
!!int 0b0 | todo | todo | todo | int | 0 | str | float | '0' | error | |||||
!!int 0b100_101 | todo | todo | todo | int | 37 | str | float | '0' | error | |||||
!!int 0x2_0 | todo | todo | todo | int | 32 | str | float | '0' | error | |||||
!!int 100_000 | todo | todo | todo | int | 100000 | str | float | '100' | error | |||||
!!int 190:20:30 | todo | todo | todo | int | 685230 | str | float | '190' | error | |||||
!!float 0.3e3 | todo | float | 300.0 | float | 300.0 | todo | int | 300 | float | '300' | float | 0.3e3 | ||
!!float +0.3e3 | todo | todo | float | 300.0 | todo | str | float | '300' | float | +0.3e3 | ||||
!!float .3e3 | todo | todo | float | 300.0 | todo | int | 300 | float | '300' | float | .3e3 | |||
!!int 0o0 | todo | todo | int | 0 | todo | str | float | '0' | error | |||||
!!int 0o10 | todo | todo | int | 8 | todo | str | float | '0' | error | |||||
!!int 0o7 | todo | todo | int | 7 | todo | str | float | '0' | error |