line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Serializer::json; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
8
|
use Cpanel::JSON::XS (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
8
|
1
|
|
|
1
|
|
5
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
451
|
use namespace::clean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub serialize { |
12
|
1
|
|
|
1
|
0
|
726
|
Cpanel::JSON::XS::encode_json($_[1]); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub deserialize { |
16
|
1
|
|
|
1
|
0
|
34
|
Cpanel::JSON::XS::decode_json($_[1]); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__END__ |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=pod |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Catmandu::Serializer - A (de)serializer from and to json |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
package MyPackage; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use Moo; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
with 'Catmandu::Serializer'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# You have now serialize and deserialize methods available |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
package main; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $obj = MyPackage->new; |
42
|
|
|
|
|
|
|
my $obj = MyPackage->new(serializer => 'json'); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$obj->serialize( { foo => 'bar' } ); # JSON |
45
|
|
|
|
|
|
|
$obj->deserialize( "{'foo':'bar'}" ); # Perl |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SEE ALSO |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
L<Catmandu::Serializer> |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |