[Koha] Parsing public reports

Alexander Borkowski Alexander.Borkowski at kau.se
Wed Jul 8 18:52:14 NZST 2020


Hi Alvaro,

The JSON data you are seeing in the browser is an array (of arrays) not a JSON object. Accordingly, $json_obj is a reference to an Perl array not a Perl hash. Hence the output

JSON OBJ:  ARRAY(0x564ec76dd7f8)

and Perl's complaint about $json_obj being treated as hash reference:

Not a HASH reference at reporte53-2.pl line 23.

The same goes for $row, too. It is also an array reference. Try to change the end of your script to this:

print "JSON OBJ:  " . $json_obj . "\n";
print scalar(@{$json_obj}), " rows:\n";

foreach my $row (@{$json_obj}){
  print join(" ", @{$row}), "\n";
}

Hope this helps,

Alexander



More information about the Koha mailing list