line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer2::Serializer::JSONMaybeXS; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
628854
|
use Moo; |
|
2
|
|
|
|
|
16869
|
|
|
2
|
|
|
|
|
17
|
|
4
|
2
|
|
|
2
|
|
2565
|
use JSON::MaybeXS (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
620
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Dancer2::Core::Role::Serializer'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has '+content_type' => ( default => sub {'application/json;charset=UTF-8'} ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub BUILD { |
13
|
|
|
|
|
|
|
warnings::warnif('deprecated', |
14
|
|
|
|
|
|
|
'Dancer2::Serializer::JSONMaybeXS is deprecated and should no longer be used'); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub serialize { |
18
|
|
|
|
|
|
|
my ($self, $entity, $options) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $config = $self->config; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
foreach (keys %$config) { |
23
|
|
|
|
|
|
|
$options->{$_} = $config->{$_} unless exists $options->{$_}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$options->{utf8} = 1 if !defined $options->{utf8}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
JSON::MaybeXS->new($options)->encode($entity); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub deserialize { |
32
|
|
|
|
|
|
|
my ($self, $entity, $options) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$options->{utf8} = 1 if !defined $options->{utf8}; |
35
|
|
|
|
|
|
|
JSON::MaybeXS->new($options)->decode($entity); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Dancer2::Serializer::JSONMaybeXS - (DEPRECATED) Serializer for handling JSON data |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Dancer2; |
47
|
|
|
|
|
|
|
set serializer => 'JSONMaybeXS'; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This is a DEPRECATED serializer engine for the L web framework. |
52
|
|
|
|
|
|
|
L now uses L natively in the default |
53
|
|
|
|
|
|
|
L (as of version C<0.201000>), so this module is no |
54
|
|
|
|
|
|
|
longer needed. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 BUGS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Report any issues on the public bugtracker. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Dan Book |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This software is Copyright (c) 2016 by Dan Book. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This is free software, licensed under: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SEE ALSO |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
L |