failing test for RT#43840
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / JSON.pm
CommitLineData
e601adda 1#
2# Catlyst::Action::Serialize::JSON.pm
be3c588a 3# Created by: Adam Jacob, Marchex, <adam@hjksolutions.com>
e601adda 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';
ebba5325 14use JSON qw(encode_json);
e601adda 15
16sub execute {
17 my $self = shift;
18 my ( $controller, $c ) = @_;
19
faf5c20b 20 my $stash_key = (
21 $controller->config->{'serialize'} ?
22 $controller->config->{'serialize'}->{'stash_key'} :
23 $controller->config->{'stash_key'}
24 ) || 'rest';
e601adda 25 my $output;
26 eval {
ebba5325 27 $output = encode_json( $c->stash->{$stash_key} );
e601adda 28 };
29 if ($@) {
30 return $@;
31 }
32 $c->response->output( $output );
33 return 1;
34}
35
361;