line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
24
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
195
|
|
2
|
5
|
|
|
5
|
|
30
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
226
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package JSON::String::BaseHandler; |
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
31
|
use Carp qw(croak); |
|
5
|
|
|
|
|
45
|
|
|
5
|
|
|
|
|
611
|
|
7
|
|
|
|
|
|
|
our @CARP_NOT = qw(JSON::String::ARRAY JSON::String::HASH); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.1.0_04'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
|
|
57
|
use Sub::Exporter -setup => { |
12
|
|
|
|
|
|
|
exports => [ |
13
|
|
|
|
|
|
|
'_reencode', |
14
|
|
|
|
|
|
|
'_recurse_wrap_value', |
15
|
|
|
|
|
|
|
'constructor' => \&build_constructor, |
16
|
|
|
|
|
|
|
] |
17
|
5
|
|
|
5
|
|
3060
|
}; |
|
5
|
|
|
|
|
46548
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require JSON::String; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub build_constructor { |
22
|
10
|
|
|
10
|
0
|
1546
|
my($class, $name, $args) = @_; |
23
|
|
|
|
|
|
|
|
24
|
10
|
|
|
|
|
25
|
my $type = $args->{type}; |
25
|
|
|
|
|
|
|
my $validator = sub { |
26
|
54
|
|
|
54
|
|
57
|
my $params = shift; |
27
|
|
|
|
|
|
|
|
28
|
54
|
50
|
33
|
|
|
249
|
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
|
|
|
|
114
|
unless ($params->{encoder}) { |
32
|
0
|
|
|
|
|
0
|
croak('encoder is a required param'); |
33
|
|
|
|
|
|
|
} |
34
|
10
|
|
|
|
|
35
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return sub { |
37
|
54
|
|
|
54
|
|
142
|
my($class, %params) = @_; |
38
|
|
|
|
|
|
|
|
39
|
54
|
|
|
|
|
108
|
$validator->(\%params); |
40
|
54
|
|
|
|
|
168
|
return bless \%params, $class; |
41
|
10
|
|
|
|
|
38
|
}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
110
|
|
|
110
|
0
|
283
|
sub encoder { shift->{encoder} } |
45
|
|
|
|
|
|
|
|
46
|
59
|
|
|
59
|
|
89
|
sub _reencode { encoder(shift)->() } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _recurse_wrap_value { |
49
|
51
|
|
|
51
|
|
67
|
my($self, $val) = @_; |
50
|
51
|
|
|
|
|
89
|
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 |