user476918 user476918 - 1 year ago 115
Perl Question

JSON string and PERL

How can I read a JSON string like this without "headers":


my $json = JSON->new->utf8;
my $perl_data = $json->decode($content);
print ref($perl_data) . "\n";

returns ARRAY. I would like each element.


Answer Source

There is an array ref around the hash references. You need to iterate over the array reference to get each element.

use Data::Dumper;

foreach my $elem (@{ $perl_data }) {
    print Dumper $elem;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download