Skip to content

cblp/yaml-sucks

Repository files navigation

YAML sucks.

YAML specification is so ambigous, that you can't be sure if tomorrow you will parse the same data from YAML file as you have yesterday.

Let's see how different implementations parse YAML code. Settings are default or near to default or typical for that language. We use JSON to represent data the uniform way.

YAML source yaml2json.hs yaml2json.pl yaml2json.py yaml2json.rb
- false
- n
- off
[false,false,false]
["","n","off"]
[false, "n", false]
[false,"n",false]
❌ yaml2json.hs: Unexpected event: expected Nothing but received Just EventStreamStart
null
null
false
- 1.23015e+3
- 12.3015e+02
- 1230.15
- -.inf
- .NaN
[1230.15,1230.15,1230.15,"-.inf",".NaN"]
["1.23015e+3","12.3015e+02","1230.15","-.inf",".NaN"]
[1230.15, 1230.15, 1230.15, -Infinity, NaN]
[1230.15,1230.15,1230.15,-Infinity,NaN]
0xC
"0xC"
"0xC"
12
12
<<
"<<"
"<<"
❌ ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:merge' in "", line 1, column 1
"<<"
<<: {}
{}
{"<<":{}}
{}
{}
"<<": {}
{}
{"<<":{}}
{"<<": {}}
{}
<<: a
{"<<":"a"}
{"<<":"a"}
❌ ConstructorError: while constructing a mapping in "", line 1, column 1 expected a mapping or list of mappings for merging, but found scalar in "", line 1, column 5
{"<<":"a"}
- 1000
- +1000
- 1_000
[1000,1000,"1_000"]
["1000","+1000","1_000"]
[1000, 1000, 1000]
[1000,1000,1000]
[8, 08, 0o10]
[8,8,"0o10"]
["8","08","0o10"]
[8, "08", "0o10"]
[8,"08","0o10"]
"Sosa did fine.\u263A"
"Sosa did fine.☺"
❌ Wide character in say at ./yaml2json.pl line 10, <> line 1.
"Sosa did fine.\u263a"
"Sosa did fine.☺"