Closed hakonhagland closed 3 years ago
Thanks, patches welcome :)
btw, the output for YAML::Syck::Dump
is:
--- {}
I think a call to SvGETMAGIC
in dump_node
fixed it. It seems to also fix #7
I think I still need help because the detection of references does not work.
I added a SvGETMAGIC
call at the top of dump_prewalk
https://github.com/ingydotnet/yaml-libyaml-pm/blob/master/LibYAML/perl_libyaml.c#L827
But this code:
my %hash : shared;
my %foo : shared;
$foo{bar} = 1;
$hash{foo} = \%foo;
$hash{x} = \%foo;
print Dump(\%hash);
returns
foo:
bar: 1
x:
bar: 1
instead of
foo: &1
bar: 1
x: *1
I pushed what I have so far to the tied
branch: https://github.com/ingydotnet/yaml-libyaml-pm/tree/tied
Hm, the fact that the reference isn't recognized seems to be normal, since Data::Dumper also outputs:
$hash = {
'foo' => {
'bar' => 1
},
'x' => {
'bar' => 1
}
};
and not
$hash = {
'x' => {
'bar' => 1
},
'foo' => $hash->{'x'}
};
I think I fixed it: #101
Finally released v0.83!
Output:
Expected output:
See also this question on stackoverflow.