Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Attempting to interpret JSON data

by mr007619 (Novice)
on May 16, 2012 at 21:36 UTC ( #970930=note: print w/ replies, xml ) Need Help??


in reply to Re: Attempting to interpret JSON data
in thread Attempting to interpret JSON data

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++ }


Comment on Re^2: Attempting to interpret JSON data
Download Code
Re^3: Attempting to interpret JSON data
by Eliya (Vicar) on May 16, 2012 at 22:10 UTC

    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970930]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-11-26 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (167 votes), past polls