nachtmsk has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to pull JSON data from an online source.
I was able to get the data and store it into $datahash.
I dereferenced that into %hashdata
Then ran through the keys. Output below.
The key named "value" is an array. I need to run through that data in that array and work with it. It is the first value in the data section I printed out below the code.
My question is how can I get the data out of that ARRAY that is in the hash %hashdata.
Thanks very much for any help.
MikeData returned =============use LWP::Simple 'get'; use Data::Dumper; use Mojo::JSON qw(decode_json encode_json); use constant URL => 'https://api.bridgedataoutput.com/api/v2/OData/tes +t/test?access_token=xxxxxxxxxxxxxx'; my $json = get URL or die "Unable to get JSON data"; my $datahash = decode_json $json; %hashdata = %$datahash; #print Dumper(%hashdata); #print $hashdata{'value'}; ## Array that holds the data foreach $key (keys %hashdata) { $value = $hashdata{$key}; print "Key $key Value $value\n\n\n"; }
Key value Value ARRAY(0x5612912d40c8) ## NEED to get into this Array and get data out.
Key @odata.context Value https://rets.io/api/v2/OData/test/
Key @odata.count Value 10006
Key @odata.nextLink Value https://rets.io/api/v2/OData/test/test?access_token=xxxxxxxxx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I Pull data out of Array inside of Hash
by choroba (Cardinal) on Jan 25, 2020 at 00:40 UTC | |
|
Re: How do I Pull data out of Array inside of Hash
by AnomalousMonk (Archbishop) on Jan 25, 2020 at 03:55 UTC | |
|
Re: How do I Pull data out of Array inside of Hash
by Anonymous Monk on Jan 25, 2020 at 07:29 UTC |