Skip to content

sdmorel/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 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.☺"

About

YAML sucks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 51.0%
  • Haskell 16.1%
  • Dockerfile 16.0%
  • Python 7.8%
  • Perl 6.2%
  • Ruby 2.9%