Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The JSON printed is likemy $RecType=uc($q->param('SearchRecType')); my $RecSubType=uc($q->param('SearchRecSubType')); my $SQL = "SELECT OBJ_ID,TITLE FROM OBJTBL"; $sth = $dbh->prepare($SQL); $sth->execute() or die "Can't execute Statement: $dbh->DBI::errstr"; my @rows; while ( my $row = $sth->fetchrow_hashref ) { push @rows, $row; } print $q->header( 'application/json' ); print encode_json( { results => \@rows } );
I'm using typeahead.js whcih does not expect the reslts: part. I can't figure out how to return the JSON one level down, without it all being a child of "results".{"results":[{"TITLE":"Title 1"OBJ_ID":"1"},{"TITLE":"Title 2","OBJ_ID" +:"2"}]}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Returning JSON problem
by marto (Cardinal) on Oct 17, 2013 at 16:35 UTC |