I have a JSON response, which I need to process in Perl to extract information out of and do further processing. The JSON document looks like this:
{
"SITE_1": [
{
"values": [
{
"time": 20170616100000,
"v": 11
}
]
}
],
"SITE_2": [
{
"values": [
{
"time": 20170616100000,
"v": 12
}
}
]
}
I'm trying to process it in a subroutine using:
my ($ref) = @_;
foreach my $row (0..$#{$ref}) {
$val = ${$ref}{$site}[0]{values}[0]{v};
Prt('-O',"$val\n"); etc.. etc...
Getting the "Not an Array error" I think due to the first item in the JSON being in a { } not [ ].
What's the simplest way to parse the data?