Dear all,
when I run the below code,I got this error
Not a HASH reference at mojo.pl line 112.
which refer the last line when I print it
How to fix it please??
I want to print the sample size (3,117) and other attributes
Thanks in advance
=========================
use strict;
use warnings;
use JSON qw( decode_json );
my $json = '{
"_embded" : {
"stes" : [ {
"SampleSize" : "3,117 ",
"ge" : false,
"gx" : false,
"Count" : 1922309,
"qualifier" : null,
"imputed" : true,
"pooled" : false,
"Comment" : null,
"Id" : "G00854",
"full" : false,
"Requested" : false,
"forms" : [ {
"manufacturer" : "ymetrix"
} ],
"ries" : [ {
"te" : "initial",
"Individuals" : 4390,
"Groups" : [ {
"Group" : "European"
} ],
"Origin" : [ ],
"Recruitment" : [ {
"majorArea" : "Europe",
"region" : "Northern Europe",
"countryName" : "U.K."
} ]
}, {
"te" : "epion",
"Individuals" : 2698,
"Groups" : [ {
"Group" : "European"
} ],<br>
"country" : [ ],
"Recruitment" : [ {
"majorArea" : "Europe",
"region" : "Western Europe",
"countryName" : "Germany"
} ]
}, {
"te" : "ation",
"Individuals" : 1649,
"Groups" : [ {
"Group" : "NR"
} ],
"country" : [ ],
"Recruitment" : [ ]
} ],
"sea" : {
"trt" : "risk"
},
"Technologies" : [ {
"Technology" : "GW"
} ],
"SampleSize" : "2,698 ",
"publicationInfo" : {
"Id" : "247",
"publicationDate" : "2016-12-01",
"publication" : "Psychiat",
"title" : "GTW.",
"author" : {
"fullname" : "Perlis RH",
"orcid" : null
},
"_links" : {
"stes" : {
"href" : " ",
"teated" : true
}
}
},
"_links" : {
"self" : {
"href" : ""
},
"sd" : {
"href" : "",
"templated" : true
},
"asmary" : {
"href" : ""
},
"ets" : {
"href" : ""
},
"ss" : {
"href" : ""
},
"aons" : {
"href" : ""
}
}
} ]
},
"_links" : {
"self" : {
"href" : ""
}
}
}';
my $decoded = decode_json($json);
# This is a Perl example of parsing a JSON object.
print "SampleSize = " . $decoded->{'_embded'}{'stes'}{'SampleSize'} .
+"\n";