in reply to Re^6: CGI Action call
in thread CGI Action call

hash- or arrayref expected

That's because $result is undefined, ie no records were found so you need to decide how to handle that. You could simply encode an empty hash.

my $json_str = encode_json( $result || {} );
poj