use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); use JSON; my $c=CGI->new(); print $c->header('application/json'); my $json = JSON->new->relaxed->pretty; my $data = { this => 'test', is => 'simple'}; print $json->encode( $data );