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"}]}