Subject: | Preserve hash key order if Tie::IxHash is used |
Hash keys are randomized even if the hash has been tied to
'Tie::IxHash'. Can this behavior be fixed so that hash keys are returned
in order? In my application, I pass along things like column data, for
which order is important.
Hope that helps,
Dan Dascalescu
#! perl -w
use strict;
use Tie::IxHash;
use JSON;
$JSON::Pretty = 1;
my %columns;
tie %columns, 'Tie::IxHash';
%columns = (
id => 'int',
field1 => 'String',
field2 => 'String',
field3 => 'String',
field4 => 'String',
field5 => 'String',
);
my $js = objToJson(\%columns);
print $js, "\n"; # randomized columns