json - How to parse complicated hash ref in perl? -
i used json::parse
decode json file. when dumped file looks printed below. need extract 'url' each of repositories. how can go doing that? have tried access elements, cannot seem them. suggestions?
how decoded .json file:
my $json_hash_ref = {}; $json_hash_ref= json_file_to_perl ($repo_json_file) or confess "no repos found";
this info dump:
$var1 = { 'repositories' => [ { 'size' => 2970, 'watchers' => 49, 'created_at' => '2012-03-20t05:04:42z', 'url' => 'http://github.cerner.com/aeon-core/aeon-topology', 'open_issues' => 0, 'followers' => 49, 'owner' => 'aeon-core', 'has_downloads' => 1, 'has_issues' => 0, 'language' => 'java', 'pushed' => '2014-06-17t18:32:37z', 'private' => ${\$var1->{'repositories'}[0]{'has_issues'}}, 'name' => 'aeon-topology', 'score' => '1', 'has_wiki' => ${\$var1->{'repositories'}[0]{'has_issues'}}, 'pushed_at' => '2014-06-17t18:32:37z', 'description' => '', 'username' => 'aeon-core', 'created' => '2012-03-20t05:04:42z', 'homepage' => '', 'forks' => 59, 'fork' => ${\$var1->{'repositories'}[0]{'has_issues'}}, 'type' => 'repo' }, { ..... },...
my @urls = map $_->{url}, @{ $json_hash_ref->{repositories} };
for info on traversing deep info structures, read perl references tutorial.
json perl hashref
No comments:
Post a Comment