line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
23
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
207
|
|
2
|
5
|
|
|
5
|
|
21
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
345
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package JSON::String::HASH; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.2.0'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use JSON::String::BaseHandler |
9
|
5
|
|
|
|
|
44
|
'_reencode', |
10
|
|
|
|
|
|
|
'_recurse_wrap_value', |
11
|
5
|
|
|
5
|
|
25
|
'constructor' => { type => 'HASH', -as => 'constructor'}; |
|
5
|
|
|
|
|
10
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
5
|
|
|
5
|
|
2288
|
*TIEHASH = \&constructor; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub FETCH { |
18
|
1201
|
|
|
1201
|
|
3221
|
my($self, $key) = @_; |
19
|
1201
|
|
|
|
|
2573
|
return $self->{data}->{$key}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub STORE { |
23
|
31
|
|
|
31
|
|
2512
|
my($self, $key, $val) = @_; |
24
|
31
|
|
|
|
|
72
|
$self->{data}->{$key} = $self->_recurse_wrap_value($val); |
25
|
31
|
|
|
|
|
71
|
$self->_reencode; |
26
|
30
|
|
|
|
|
59
|
return $val; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub DELETE { |
30
|
1
|
|
|
1
|
|
288
|
my($self, $key) = @_; |
31
|
1
|
|
|
|
|
3
|
my $val = delete $self->{data}->{$key}; |
32
|
1
|
|
|
|
|
4
|
$self->_reencode; |
33
|
1
|
|
|
|
|
2
|
return $val; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub CLEAR { |
37
|
1
|
|
|
1
|
|
291
|
my $self = shift; |
38
|
1
|
|
|
|
|
1
|
%{$self->{data}} = (); |
|
1
|
|
|
|
|
3
|
|
39
|
1
|
|
|
|
|
3
|
$self->_reencode; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub EXISTS { |
43
|
23
|
|
|
23
|
|
193
|
my($self, $key) = @_; |
44
|
23
|
|
|
|
|
44
|
return exists $self->{data}->{$key}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub FIRSTKEY { |
48
|
1106
|
|
|
1106
|
|
2591
|
my $self = shift; |
49
|
1106
|
|
|
|
|
748
|
keys(%{$self->{data}}); # reset the iterator |
|
1106
|
|
|
|
|
1188
|
|
50
|
1106
|
|
|
|
|
761
|
each %{$self->{data}}; |
|
1106
|
|
|
|
|
2461
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
165
|
|
|
165
|
|
129
|
sub NEXTKEY { each %{shift->{data}} } |
|
165
|
|
|
|
|
383
|
|
54
|
2
|
|
|
2
|
|
256
|
sub SCALAR { scalar( %{ shift->{data} } ) } |
|
2
|
|
|
|
|
16
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
JSON::String::HASH - Handle hashes for JSON::String |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DESCRIPTION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This module is not intended to be used directly. It is used by |
67
|
|
|
|
|
|
|
L to tie behavior to an hash. Any time the hash is changed, |
68
|
|
|
|
|
|
|
the top-level data structure is re-encoded and the serialized representation |
69
|
|
|
|
|
|
|
saved back to the original location. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L, L |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHOR |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Anthony Brummett |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Copyright 2015, Anthony Brummett. This module is free software. It may |
82
|
|
|
|
|
|
|
be used, redistributed and/or modified under the same terms as Perl itself. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |