summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2010-05-16 19:18:46 -0400
committerJason Woodward2010-05-16 19:18:46 -0400
commit68dd1b3b2e3b437c5db57b9a6351ad626a34f1bc (patch)
tree72abce88aadc320e5c258683ae3e478b9f7a4daf
parent673e92938f81f75b11547546f66d10a96367696d (diff)
downloadJaos-WebApp-68dd1b3b2e3b437c5db57b9a6351ad626a34f1bc.tar.gz
updated ::Render::JSON
-rw-r--r--lib/Jaos/WebApp/Render/JSON.pm10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Jaos/WebApp/Render/JSON.pm b/lib/Jaos/WebApp/Render/JSON.pm
index 988e904..79121f5 100644
--- a/lib/Jaos/WebApp/Render/JSON.pm
+++ b/lib/Jaos/WebApp/Render/JSON.pm
@@ -5,15 +5,15 @@ use JSON ();
sub register
{
- my ($class, $app, %conf) = @_;
+ my ($class, $app, $conf) = @_;
my $json = JSON->new();
$app->add_renderer(
json => sub {
my ($controller, $data, %options) = @_;
- $controller->res->content_type('text/x-json');
- $controller->res->body($json->encode($data));
+ $controller->app->res->content_type('text/x-json');
+ $controller->app->res->body($json->encode($data));
}
);
}
@@ -38,13 +38,13 @@ Jaos::WebApp::Render::JSON - Render output with JSON
sub data
{
my $self = shift;
- $self->render( json => '{ "id":"1", "name":"me" }');
+ $self->render( json => { id => 1, name => 'me' } );
}
1;
=head1 DESCRIPTION
-This is a L<JSON> renderer for L<Jaos::WebApp>.
+This is a L<JSON> renderer for L<Jaos::WebApp>. A hash or array reference is passed to L<JSON> encode.
=head1 METHODS