File: JSON.pm

package info (click to toggle)
libcatalyst-action-rest-perl 1.21-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 476 kB
  • sloc: perl: 1,750; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 652 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package Test::Serialize::Controller::JSON;

use namespace::autoclean;
use Moose;

BEGIN { extends qw/Catalyst::Controller::REST/ };

__PACKAGE__->config(
    'stash_key' => 'rest',
    'json_options' => {
        relaxed => 1,
    },
    'map'       => {
        'text/x-json'        => 'JSON',
    },
);

sub monkey_json_put : Path("/monkey_json_put") : ActionClass('Deserialize') {
    my ( $self, $c ) = @_;
    if ( ref($c->req->data) eq "HASH" ) {
        my $out = ($c->req->data->{'sushi'}||'') . ($c->req->data->{'chicken'}||'');
        utf8::encode($out);
        $c->res->output( $out );
    } else {
        $c->res->output(1);
    }
}

1;