Line | |
---|
1 | package LATMOS::Accounts::Web::View::Json; |
---|
2 | |
---|
3 | use strict; |
---|
4 | use base 'Catalyst::View::JSON'; |
---|
5 | use utf8; |
---|
6 | |
---|
7 | __PACKAGE__->config( |
---|
8 | allow_callback => 1, # defaults to 0 |
---|
9 | callback_param => 'cb', # defaults to 'callback' |
---|
10 | expose_stash => 'data', # defaults to everything |
---|
11 | ); |
---|
12 | |
---|
13 | use JSON::XS (); |
---|
14 | |
---|
15 | sub encode_json { |
---|
16 | my($self, $c, $data) = @_; |
---|
17 | my $encoder = JSON::XS->new->pretty->allow_nonref; |
---|
18 | my $res = $encoder->encode($data); |
---|
19 | # This fix an issue on old Catalyst... |
---|
20 | utf8::decode($res); |
---|
21 | $res |
---|
22 | } |
---|
23 | |
---|
24 | |
---|
25 | =head1 NAME |
---|
26 | |
---|
27 | LATMOS::Accounts::Web::View::Json - Catalyst JSON View |
---|
28 | |
---|
29 | =head1 SYNOPSIS |
---|
30 | |
---|
31 | See L<LATMOS::Accounts::Web> |
---|
32 | |
---|
33 | =head1 DESCRIPTION |
---|
34 | |
---|
35 | Catalyst JSON View. |
---|
36 | |
---|
37 | =head1 AUTHOR |
---|
38 | |
---|
39 | olivier |
---|
40 | |
---|
41 | =head1 LICENSE |
---|
42 | |
---|
43 | This library is free software, you can redistribute it and/or modify |
---|
44 | it under the same terms as Perl itself. |
---|
45 | |
---|
46 | =cut |
---|
47 | |
---|
48 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.