http://www.perlmonks.org?node_id=633012


in reply to Re^6: JSON module
in thread JSON module

@output should be an array of hashrefs.

while ( my $row = $sth->fetchrow_hashref ) { my %data; $data{ col1 } = 'bar'; push @output, \%data; }

Then converting it to JSON will make it look something like (i've added some formatting):

{ "myData" : [ { "col1" : "bar" }, { "col1" : "bar" }, # etc ... ] }

HTH.

--
"Go up to the next female stranger you see and tell her that her "body is a wonderland."
My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
" (src)