line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hoppy::Formatter::JSON; |
2
|
7
|
|
|
7
|
|
1875
|
use strict; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
268
|
|
3
|
7
|
|
|
7
|
|
41
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
227
|
|
4
|
7
|
|
|
7
|
|
72
|
use base qw( Hoppy::Base ); |
|
7
|
|
|
|
|
29
|
|
|
7
|
|
|
|
|
1185
|
|
5
|
7
|
|
|
7
|
|
9696
|
use Encode; |
|
7
|
|
|
|
|
99122
|
|
|
7
|
|
|
|
|
705
|
|
6
|
7
|
|
|
7
|
|
3563
|
use JSON; |
|
7
|
|
|
|
|
64473
|
|
|
7
|
|
|
|
|
350
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub serialize { |
9
|
3
|
|
|
3
|
1
|
70
|
my ( $self, $data, $code ) = @_; |
10
|
3
|
|
|
|
|
32
|
my $json = JSON::to_json($data); |
11
|
3
|
50
|
|
|
|
359
|
if ( Encode::is_utf8($json) ) { |
12
|
3
|
|
|
|
|
16
|
utf8::decode($json); |
13
|
|
|
|
|
|
|
} |
14
|
3
|
|
|
|
|
18
|
return $json; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub deserialize { |
18
|
4
|
|
|
4
|
1
|
2365
|
my ( $self, $json, $code ) = @_; |
19
|
4
|
|
|
|
|
56
|
$json = decode( "utf8", $json ); |
20
|
4
|
|
|
|
|
369
|
my $data = JSON::from_json($json); |
21
|
4
|
|
|
|
|
338
|
return $data; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
__END__ |