http://qs321.pair.com?node_id=984872

tevolo has asked for the wisdom of the Perl Monks concerning the following question:

Hello wise monks.

I have a very large json formatted file that I am trying to extract specific values from. The json file looks like such:

{ "Content_ID" : { "CNBP_021687" : { "Title" : "Molecule of the Week - + Pyruvic Acid", "Type" : "Article", "Web Extension" : "doc", "WebSite" : "PublicWebSite", "WebSiteSection" : "PublicWebSite:841" }, "CNBP_021688" : { "Title" : "STEM Education Coalition Supports V +olunteer Service Legislation", "Type" : "Article", "Web Extension" : "pdf", "WebSite" : "PublicWebSite", "WebSiteSection" : "PublicWebSite:1892" }, "CNBP_021691" : { "Title" : "WCC Lectureship Award", "Type" : "Article", "Web Extension" : "doc", "WebSite" : "PublicWebSite", "WebSiteSection" : "PublicWebSite:1367" },

And my script looks like such:

#!c:/strawberry/perl/bin/perl.exe use JSON; use Data::Dumper; use warnings; use strict; use utf8; use URI::Escape; my $text; my $json =""; my $object = ""; my $item = ""; sub extract_json { my $file = shift; local $/; #enable slurp open my $fh, "<", "$file"; $json = <$fh>; return $json; } my $jobj = extract_json('C:\Temp3\articlePaagesJson.txt'); use Encode; $object = JSON::XS->new->decode (decode "UTF-8", $jobj); # print Dumper $object foreach $item (@{$object->{Content_ID}} ){ print " do nothing \n"; };

When I use data dumber the values print but I keep getting an error Not an ARRAY reference at

I am trying to exctract the content ID the title and the web extension if that helps at all. I keep trying everything and anything I see online and on the board but nothing is working.

Any help would be greatly appreciated