Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: JSON and Perl Objects - How to access data?

by AnomalousMonk (Archbishop)
on Sep 06, 2015 at 13:04 UTC ( [id://1141194]=note: print w/replies, xml ) Need Help??


in reply to Re^4: JSON and Perl Objects - How to access data?
in thread JSON and Perl Objects - How to access data?

See also the Data Structures Cookbook.

I'm going to have to wrap my head around ...

One way to go about that is to dump (see Data::Dumper; see also Data::Dump) the Perl object reference in stages, and from the inside out (i.e., top level to bottom):
    print Dumper $obj->{'items'};
will show that you have a reference to an array. Then
    print Dumper $obj->{'items'}->[1];
will show that one element of the array contains a hash reference. Finally,
    print Dumper ${ $obj->{'items'}->[1] }{'name'};
will show the value of one key of the referent.

Update: BTW: the expression
    ${ $obj->{'items'}->[1] }{'name'}
is equivalent to the more concise and IMHO preferable
    $obj->{'items'}[1]{'name'}


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found