gezb has asked for the wisdom of the Perl Monks concerning the following question:
Hi, i'm trying to extract data from a json object but at a loss. I can see the perl data object via -d:ptkdb but cant reference the individual key, values. Both data dumps are the same. Any help would be appreciated. Thanks in advance
#!/usr/bin/env perl use strict; use Data::Dumper; use JSON; my $data = '[{"acc_id":0,"acc_cust_id":17,"acc_po_ref":"qwerty","acc_n +ame":"EX3000","acc_phonenum":"0121777777","acc_email":"ex3000@mail.co +m","acc_expires":null}]'; my @obj = from_json($data); my $obj = from_json($data); print Dumper(@obj)."\n"; print Dumper($obj)."\n"; $VAR1 = [ { 'acc_name' => 'EX3000', 'acc_po_ref' => 'qwerty', 'acc_expires' => undef, 'acc_email' => 'ex3000@mail.com', 'acc_id' => 0, 'acc_phonenum' => '0121777777', 'acc_cust_id' => 17 } ]; #print "$obj[0]{'acc_id'}\n"; #print "$obj[0]->{'acc_id'}\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting data from json object
by Corion (Patriarch) on Mar 21, 2014 at 08:08 UTC | |
|
Re: Extracting data from json object
by McA (Priest) on Mar 21, 2014 at 08:15 UTC |