line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
18
|
use strict; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
141
|
|
2
|
5
|
|
|
5
|
|
17
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
148
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package JSON::String::BaseHandler; |
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
19
|
use Carp qw(croak); |
|
5
|
|
|
|
|
31
|
|
|
5
|
|
|
|
|
416
|
|
7
|
|
|
|
|
|
|
our @CARP_NOT = qw(JSON::String::ARRAY JSON::String::HASH); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.2.0'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
|
|
46
|
use Sub::Exporter -setup => { |
12
|
|
|
|
|
|
|
exports => [ |
13
|
|
|
|
|
|
|
'_reencode', |
14
|
|
|
|
|
|
|
'_recurse_wrap_value', |
15
|
|
|
|
|
|
|
'constructor' => \&build_constructor, |
16
|
|
|
|
|
|
|
] |
17
|
5
|
|
|
5
|
|
2630
|
}; |
|
5
|
|
|
|
|
38799
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require JSON::String; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub build_constructor { |
22
|
10
|
|
|
10
|
0
|
1811
|
my($class, $name, $args) = @_; |
23
|
|
|
|
|
|
|
|
24
|
10
|
|
|
|
|
25
|
my $type = $args->{type}; |
25
|
|
|
|
|
|
|
my $validator = sub { |
26
|
54
|
|
|
54
|
|
53
|
my $params = shift; |
27
|
|
|
|
|
|
|
|
28
|
54
|
50
|
33
|
|
|
234
|
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
|
|
|
|
95
|
unless ($params->{encoder}) { |
32
|
0
|
|
|
|
|
0
|
croak('encoder is a required param'); |
33
|
|
|
|
|
|
|
} |
34
|
10
|
|
|
|
|
39
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return sub { |
37
|
54
|
|
|
54
|
|
122
|
my($class, %params) = @_; |
38
|
|
|
|
|
|
|
|
39
|
54
|
|
|
|
|
94
|
$validator->(\%params); |
40
|
54
|
|
|
|
|
152
|
return bless \%params, $class; |
41
|
10
|
|
|
|
|
42
|
}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
110
|
|
|
110
|
0
|
264
|
sub encoder { shift->{encoder} } |
45
|
|
|
|
|
|
|
|
46
|
59
|
|
|
59
|
|
74
|
sub _reencode { encoder(shift)->() } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _recurse_wrap_value { |
49
|
51
|
|
|
51
|
|
57
|
my($self, $val) = @_; |
50
|
51
|
|
|
|
|
82
|
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 |