I would like to parse the YAML
foo: &foo
- a: 1
bar:
<<: *foo
When I try to do this using ruby's YAML I get an odd result:
YAML.load("
foo: &foo
- a: 1
bar:
<<: *foo
")
=> {"foo"=>[{"a"=>1}], "bar"=>{"<<"=>[{"a"=>1}]}}
Note the appearance of the odd <<
. I would have expected
{"foo"=>[{"a"=>1}], "bar"=>[{"a"=>1}]}
Am I misunderstanding how to use the YAML syntax?
In case relevant:
ENV['RBENV_VERSION']
=> "2.4"
YAML.libyaml_version
=> [0, 1, 4]
I'm also a bit suspicious of my syntax because when I plug this into an online yaml parser I get different output , but also different from what I expect:
{
"foo": [{"a": 1}],
"bar": {"a": 1}
}
(sorry, that's json -- but the point is that in the bar
values is not wrapped in array brackets as I would expect.