0.60 release branch
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / JSON.pm
CommitLineData
e601adda 1#
2# Catlyst::Action::Serialize::JSON.pm
3# Created by: Adam Jacob, Marchex, <adam@marchex.com>
4# Created on: 10/12/2006 03:00:32 PM PDT
5#
6# $Id$
7
8package Catalyst::Action::Serialize::JSON;
9
10use strict;
11use warnings;
12
13use base 'Catalyst::Action';
14use JSON::Syck;
15
16sub execute {
17 my $self = shift;
18 my ( $controller, $c ) = @_;
19
20 my $stash_key = $controller->config->{'serialize'}->{'stash_key'} || 'rest';
21 my $output;
22 eval {
23 $output = JSON::Syck::Dump($c->stash->{$stash_key});
24 };
25 if ($@) {
26 return $@;
27 }
28 $c->response->output( $output );
29 return 1;
30}
31
321;