package Web::App::Presenter::JSON;
# $Id: JSON.pm,v 1.5 2009/03/29 10:08:42 apla Exp $
use Class::Easy;
use JSON;
use Web::App::Presenter;
use base qw(Web::App::Presenter);
1;
sub headers {
my $
ontent-Type' => 'text/plain; charset=utf-8');
# $headers->header ('Content-Type' => 'application/json');
$headers->header ('Cache-Control' => 'no-store');
# $headers->header ('Expires' => localtime
y $json = JSON->new;
$json->allow_blessed (1);
$json->convert_blessed (1);
$json->pretty (1);
$json->space_before (0);
$json->space_after (0);
my $json_text;
my $t = timer ('dumping json');
# 1. set correct presentation
# 2. remove redirect header
$app->set_presentation ({type => 'json'});
return;
}
sub new {
my $class = shift;
my $self = dclone ($template);
if ($Class::
$pack->root;
my $global_config_patch_json = delete $files->{global_config_patch_json};
my $local_config_patch_json = delete $files->{local_config_patch_json};
debug "storing config files";
hin helper we have json structures
my $serializer = Project::Easy::Config->serializer ('json');
# global config
my $patch = $serializer->parse_string ($global_config_patch_json);
$pack->conf_pat
n
$local_config_patch_json = Project::Easy::Config::string_from_template (
$local_config_patch_json,
$vars
);
$patch = $serializer->parse_string ($local_config_patch_json);
$pack->fixup_path->
content output";
# fix for "Wide characters to print"
binmode STDOUT, ":utf8";
utf8::decode ($content);
$| = 1;
print $content;
}
sub TO_JSON {
my $self = shift;
return {%$self};
}
1;