use warnings; use strict; use JSON; #use vsutils; use Data::Dumper; use Ref::Util qw(is_arrayref is_hashref); my $companyNumber = 'NF001553'; my $request = "https://api.company-information.service.gov.uk/company/".$companyNumber."/officers"; my $curl = `curl -s --user some-long-secret-api-access-string:"" $request` || die "SOMETHING IS WRONG HERE\n"; my $decodedJSON = decode_json($curl); print Dumper($decodedJSON); if (is_hashref($decodedJSON)){ print "The JSON is a HashRef\n"; foreach my $key (keys %$decodedJSON) { if (is_hashref($key)) { print "its another hash\n" ; } elsif(is_arrayref($key)){ print "its an array ref" } else{ print Dumper($key); print $key." is neither a hashref nor an arrayref\n"; } } }