App::HistHub::Web::View::JSON - Catalyst JSON View


App-HistHub documentation Contained in the App-HistHub distribution.

Index


Code Index:

NAME

Top

App::HistHub::Web::View::JSON - Catalyst JSON View

SYNOPSIS

Top

See App::HistHub::Web

DESCRIPTION

Top

Catalyst JSON View.

AUTHOR

Top

Daisuke Murase

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


App-HistHub documentation Contained in the App-HistHub distribution.

package App::HistHub::Web::View::JSON;
use strict;
use base 'Catalyst::View::JSON';

use JSON::XS ();

__PACKAGE__->config(
    allow_callback   => 0,
    expose_stash     => 'json',
    no_x_json_header => 1,
);

sub new {
    my $self = shift->SUPER::new(@_);
    $self->{encoder} = JSON::XS->new->latin1;
    $self;
}

sub encode_json {
    my ($self, $c, $data) = @_;
    $self->{encoder}->encode($data);
}

1;