CC: | bug-JSON-MultiValueOrdered [...] rt.cpan.org |
Subject: | Re: Question about your module: JSON::MultiValueOrdered |
Date: | Tue, 10 Dec 2013 17:09:15 -0000 |
To: | "Pablo Graziano" <pablo [...] compugenic.com> |
From: | "Toby Inkster" <mail [...] tobyinkster.co.uk> |
Tie::Hash::MultiValueOrdered is a module for tie-ing hashes, so you're not
supposed to create objects of that class directly. The following code
should do the trick, but this probably needs better documentation...
use strict;
use warnings;
use JSON::MultiValueOrdered;
sub H {
tie my %hash, 'Tie::Hash::MultiValueOrdered';
while (my ($k, $v) = splice(@_, 0, 2)) {
$hash{$k} = $v;
}
return \%hash;
}
my $data = H(
name => 'Joe',
methods => H(
parent => 'arg1',
sibling => 'arg2',
parent => 'arg3',
),
);
print JSON::MultiValueOrdered->new(pretty => 1)->encode($data);