line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
18
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
139
|
|
2
|
5
|
|
|
5
|
|
18
|
use warnings; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
146
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package JSON::String::BaseHandler; |
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
17
|
use Carp qw(croak); |
|
5
|
|
|
|
|
29
|
|
|
5
|
|
|
|
|
379
|
|
7
|
|
|
|
|
|
|
our @CARP_NOT = qw(JSON::String::ARRAY JSON::String::HASH); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.1.0_03'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
|
|
49
|
use Sub::Exporter -setup => { |
12
|
|
|
|
|
|
|
exports => [ |
13
|
|
|
|
|
|
|
'_reencode', |
14
|
|
|
|
|
|
|
'_recurse_wrap_value', |
15
|
|
|
|
|
|
|
'constructor' => \&build_constructor, |
16
|
|
|
|
|
|
|
] |
17
|
5
|
|
|
5
|
|
5324
|
}; |
|
5
|
|
|
|
|
40197
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require JSON::String; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub build_constructor { |
22
|
10
|
|
|
10
|
0
|
1641
|
my($class, $name, $args) = @_; |
23
|
|
|
|
|
|
|
|
24
|
10
|
|
|
|
|
21
|
my $type = $args->{type}; |
25
|
|
|
|
|
|
|
my $validator = sub { |
26
|
54
|
|
|
54
|
|
51
|
my $params = shift; |
27
|
|
|
|
|
|
|
|
28
|
54
|
50
|
33
|
|
|
219
|
unless ($params->{data} and ref($params->{data}) eq $type) { |
29
|
0
|
|
|
|
|
0
|
croak(qq(Expected $type ref for param 'data', but got ).ref($params->{data})); |
30
|
|
|
|
|
|
|
} |
31
|
54
|
50
|
|
|
|
131
|
unless ($params->{encoder}) { |
32
|
0
|
|
|
|
|
0
|
croak('encoder is a required param'); |
33
|
|
|
|
|
|
|
} |
34
|
10
|
|
|
|
|
32
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return sub { |
37
|
54
|
|
|
54
|
|
118
|
my($class, %params) = @_; |
38
|
|
|
|
|
|
|
|
39
|
54
|
|
|
|
|
88
|
$validator->(\%params); |
40
|
54
|
|
|
|
|
152
|
return bless \%params, $class; |
41
|
10
|
|
|
|
|
38
|
}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
110
|
|
|
110
|
0
|
266
|
sub encoder { shift->{encoder} } |
45
|
|
|
|
|
|
|
|
46
|
59
|
|
|
59
|
|
83
|
sub _reencode { encoder(shift)->() } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _recurse_wrap_value { |
49
|
51
|
|
|
51
|
|
54
|
my($self, $val) = @_; |
50
|
51
|
|
|
|
|
91
|
return JSON::String::_construct_object($val, undef, encoder($self)); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
JSON::String::BaseHandler - Common code for hashes and arrays in JSON::String |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This module is not intended to be used directly. It contains code common to |
64
|
|
|
|
|
|
|
L and L. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SEE ALSO |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L, L, L |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 AUTHOR |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Anthony Brummett |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 COPYRIGHT |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Copyright 2015, Anthony Brummett. This module is free software. It may |
77
|
|
|
|
|
|
|
be used, redistributed and/or modified under the same terms as Perl itself. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |