Yup. It's just hashes with some + and - prefixes on the keys. (For use
with Data::ModeMerge).
$ perl -MData::Dumper -MYAML::XS -0777 -ne'$Data::Dumper::Indent=1;
print Dumper Load $_'
us_address
$VAR1 =
[
'address',
{
'+allowed_keys' =>
[
'zipcode'
],
'+keys' =>
{
'country' =>
[
'str',
{
'is' =>
'US'
}
],
'zipcode' => [
'str',
{
'len' => 5,
'required' => 'Yes',
'match' => '^\\d{5}$'
}
]
},
'+required_keys' => [
'zipcode'
],
'-keys' => {
'postcode' => undef
},
'-required_keys' => [
'postcode'
],
'-allowed_keys' => [
'postcode'
]
}
];
On Wed Dec 16 23:57:37 2009, adam@ali.as wrote:
Show quoted text> Is this meant to be legal YAML?
>
> It looks weirdly like a diff to me...
>
> Adam K
>
> 2009/12/17 steven haryanto via RT <bug-YAML@rt.cpan.org>:
> > Wed Dec 16 12:19:50 2009: Request 52837 was acted upon.
> > Transaction: Ticket created by SHARYANTO
> > Queue: YAML
> > Subject: Can't handle this sample data
> > Broken in: (no value)
> > Severity: (no value)
> > Owner: Nobody
> > Requestors: sharyanto@cpan.org
> > Status: new
> > Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=52837 >
> >
> >
> > $ cat us_address
> > - address
> > - +keys:
> > zipcode: [str, {len: 5, match: '^\d{5}$', required: Yes}]
> > country: [str, {is: US}]
> > -keys:
> > postcode: ~
> > -allowed_keys: [postcode]
> > -required_keys: [postcode]
> > +required_keys: [zipcode]
> > +allowed_keys: [zipcode]
> >
> > $ perl -MYAML -0777 -ne'print Dump Load $_' us_address
> > YAML Error: Inconsistent indentation level
> > Code: YAML_PARSE_ERR_INCONSISTENT_INDENTATION
> > Line: 3
> > Document: 1
> > at /usr/local/share/perl/5.10.0/YAML.pm line 36
> >
> > but all the other modules I tried handles it fine (although
YAML::Tiny
Show quoted text> > parses it totally wrongly):
> >
> > $ perl -MYAML::XS -0777 -ne'print Dump Load $_' us_address
> > ---
> > ...
> >
> > $ perl -MYAML::Tiny -0777 -ne'print Dump Load $_' us_address
> > ---
> > ...
> >
> > $ perl -MYAML::XS -0777 -ne'print Dump Load $_' us_address
> > ---
> > ...
> >
> > $ ruby -ryaml -0777 -ne'puts YAML::load($_).to_yaml' us_address
> > ---
> > ...
> >
> >
> >