in reply to Returning data

It looks like you have the part that gets the titles from the DB correct. Consider this:
use strict; use warnings; use 5.10.0; use JSON; use Data::Dump qw(pp); my %output; foreach my $title ("Valls", "AUT15605", "10UT15605") { push @{$output{items}}, {title => $title}; } my $output_json = encode_json \%output; say $output_json; pp \%output; __END__ This is what the Perl structure looks like: { items => [ { title => "Valls" }, { title => "AUT15605" }, { title => "10UT15605" }, ], } This is the encoded JSON: {"items":[{"title":"Valls"},{"title":"AUT15605"},{"title":"10UT15605"} +]}
"items" is a hash key which has a value that is a reference to an array of anon hashes.

Replies are listed 'Best First'.
Re^2: Returning data
by frank1 (Monk) on Apr 21, 2024 at 12:33 UTC

    thanks this has worked for me