in reply to Attempting to interpret JSON data

As a simple rule, for every { in the Data::Dumper output you need a { for dereferencing, and for every [ in the dumper output you need a [ for dereferencing:
# $VAR1 = { 'lbvserver' => [ {, 'name' => 'name1', ' # ^ ^ ^ my $name = $decode_json->{lbvserver}[0]{name}; # ^ ^ ^

perlreftut and maybe perldsc should teach you enough to figure it out.

Replies are listed 'Best First'.
Re^2: Attempting to interpret JSON data
by mr007619 (Novice) on May 16, 2012 at 20:24 UTC
Re^2: Attempting to interpret JSON data
by mr007619 (Novice) on May 16, 2012 at 21:36 UTC

    One last question here after finally starting to understand array and hash references. So since this is a mix of both, is the best way to loop through each array of hashes to grab the count of array elements as such

    $count = -1; foreach $elem (@{$decodejs->{'lbvserver'}}) { $count++; } $num = 0; while ($num <= $count) { print "$decodejs->{'lbvserver'}[$num]{'valueIwant'}\n"; $num++ }

      Maybe simply

      for my $elem (@{$decodejs->{lbvserver}}) { print "$elem->{valueIwant}\n"; }

        Yes thank you now I realize that was a reference and much easier - understanding this better now, thanks a lot.