YAML sucks.
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
inputs Add merge6.yaml, "rq" target Nov 18, 2017
Dockerfile Add merge6.yaml, "rq" target Nov 18, 2017
HOWTO.md Update HOWTO.md Jul 18, 2015
README.md Add merge6.yaml, "rq" target Nov 18, 2017
preamble.md [+] preamble Jul 20, 2015
run.sh Add merge6.yaml, "rq" target Nov 18, 2017
yaml2json.hs [m] update to Ubuntu 16.04 Jul 22, 2016
yaml2json.pl set binmode :utf8 Nov 15, 2017
yaml2json.py [m] cleaner Haskell and Python Jul 19, 2015
yaml2json.rb [+] Ruby Jul 20, 2015

README.md

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 rq
- false
- n
- off
[false,false,false]
["","n","off"]
[false, "n", false]
[false,"n",false]
[false,"n","off"]
yaml2json.hs: UnexpectedEvent {_received = Nothing, _expected = Just EventStreamStart}
null
null
/usr/lib/ruby/1.9.1/json/common.rb:216:in `generate': only generation of JSON objects or arrays allowed (JSON::GeneratorError) from /usr/lib/ruby/1.9.1/json/common.rb:216:in `generate' from /usr/lib/ruby/1.9.1/json/common.rb:352:in `dump' from ./yaml2json.rb:6:in `'
- -.inf
- .NaN
["-.inf",".NaN"]
["-.inf",".NaN"]
[-Infinity, NaN]
[-Infinity,NaN]
["-.inf",".NaN"]
- 1.23015e+3
- 12.3015e+02
- 1230.15
[1230.15,1230.15,1230.15]
["1.23015e+3","12.3015e+02","1230.15"]
[1230.15, 1230.15, 1230.15]
[1230.15,1230.15,1230.15]
[1230.15,1230.15,1230.15]
0xC
"0xC"
"0xC"
12
/usr/lib/ruby/1.9.1/json/common.rb:216:in `generate': only generation of JSON objects or arrays allowed (JSON::GeneratorError) from /usr/lib/ruby/1.9.1/json/common.rb:216:in `generate' from /usr/lib/ruby/1.9.1/json/common.rb:352:in `dump' from ./yaml2json.rb:6:in `'
12
<<
"\u003c\u003c"
"<<"
ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:merge' in "", line 1, column 1 /usr/lib/ruby/1.9.1/json/common.rb:216:in `generate': only generation of JSON objects or arrays allowed (JSON::GeneratorError) from /usr/lib/ruby/1.9.1/json/common.rb:216:in `generate' from /usr/lib/ruby/1.9.1/json/common.rb:352:in `dump' from ./yaml2json.rb:6:in `'
"<<"
<<: {}
{}
{"<<":{}}
{}
{"<<":{}}
{"<<":{}}
"<<": {}
{}
{"<<":{}}
{"<<": {}}
{"<<":{}}
{"<<":{}}
<<: a
{"\u003c\u003c":"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"}
{"<<":"a"}
a: &alias
    k1: v1
    k2: v2

b: <<: *alias k1: override k3: v3

{"a":{"k2":"v2","k1":"v1"},"b":{"k3":"v3","k2":"v2","k1":"override"}}
{"b":{"k1":"override","<<":{"k1":"v1","k2":"v2"},"k3":"v3"},"a":{"k1":"v1","k2":"v2"}}
{"a": {"k2": "v2", "k1": "v1"}, "b": {"k3": "v3", "k2": "v2", "k1": "override"}}
{"a":{"k1":"v1","k2":"v2"},"b":{"k1":"override","k2":"v2","k3":"v3"}}
{"a":{"k1":"v1","k2":"v2"},"b":{"<<":{"k1":"v1","k2":"v2"},"k1":"override","k3":"v3"}}
- 1000
- +1000
- 1_000
[1000,1000,"1_000"]
["1000","+1000","1_000"]
[1000, 1000, 1000]
[1000,1000,1000]
[1000,1000,"1_000"]
[8, 08, 0o10, 010]
[8,8,"0o10",10]
["8","08","0o10","010"]
[8, "08", "0o10", 8]
[8,"08",8,8]
[8,8,8,10]
"Sosa did fine.\u263A"
"Sosa did fine.☺"
Wide character in say at ./yaml2json.pl line 10, <> line 1.
"Sosa did fine.\u263a"
/usr/lib/ruby/1.9.1/json/common.rb:216:in `generate': only generation of JSON objects or arrays allowed (JSON::GeneratorError) from /usr/lib/ruby/1.9.1/json/common.rb:216:in `generate' from /usr/lib/ruby/1.9.1/json/common.rb:352:in `dump' from ./yaml2json.rb:6:in `'
"Sosa did fine.☺"