in reply to Mojolicios - render json with field names
Instad of moving your data from an array to an array of hashes (AoH) afterwards, let DBI do the work:
my $sql = 'select product, price from table'; my $results = $dbh->selectall_arrayref($sql, { Slice => {} }); warn Dumper $results;
This will return the list as hashes just like you want to use them.
Your syntax for JSON seems somewhat off, because JSON only accepts : for objects / hashes and not for arrays I think.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Mojolicios - render json with field names
by Anonymous Monk on Nov 10, 2016 at 14:49 UTC | |
by Corion (Patriarch) on Nov 10, 2016 at 14:57 UTC | |
by Anonymous Monk on Nov 10, 2016 at 16:08 UTC |