I am a Perl newbie and want to loop over JSON data.
This is my code:
use JSON::XS;
my $jsonxx = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
my $text = decode_json($jsonxx);
foreach my $key(keys %$text) {
print "$key\n";
}
and output is:
e
c
a
b
d
But I want output in the order of key-value pair given.
Expected Output:
a
b
c
d
e
Can anyone please help?