in reply to Re^2: JSON module
in thread JSON module
The only difference would be that you need to send back the proper HTTP headers first before the JSON data:
use strict; use warnings; use CGI; use DBI; use JSON; my @output; my $dbh = DBI->connect('dbi:Pg:dbname=foo','bar','baz'); my $sth = $dbh->prepare('select * from qux'); $sth->execute; while ( my $row = $sth->fetchrow_hashref ){ push @output, $row; } my $cgi = CGI->new; print $cgi->header( 'application/json' ); print objToJson( { myData => \@output } );
--
"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)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: JSON module
by hallikpapa (Scribe) on Aug 14, 2007 at 20:30 UTC | |
by LTjake (Prior) on Aug 15, 2007 at 12:06 UTC | |
by hallikpapa (Scribe) on Aug 15, 2007 at 21:49 UTC | |
by LTjake (Prior) on Aug 16, 2007 at 11:54 UTC |
In Section
Seekers of Perl Wisdom