source: trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/View/Json.pm @ 2054

Last change on this file since 2054 was 1631, checked in by nanardon, 8 years ago

Workaround an utf8 issue

File size: 837 bytes
Line 
1package LATMOS::Accounts::Web::View::Json;
2
3use strict;
4use base 'Catalyst::View::JSON';
5use 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
13use JSON::XS ();
14
15sub 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
27LATMOS::Accounts::Web::View::Json - Catalyst JSON View
28
29=head1 SYNOPSIS
30
31See L<LATMOS::Accounts::Web>
32
33=head1 DESCRIPTION
34
35Catalyst JSON View.
36
37=head1 AUTHOR
38
39olivier
40
41=head1 LICENSE
42
43This library is free software, you can redistribute it and/or modify
44it under the same terms as Perl itself.
45
46=cut
47
481;
Note: See TracBrowser for help on using the repository browser.