line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Session::Serialization::JSON; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
893
|
use 5.006; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
182
|
|
4
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
128
|
|
5
|
4
|
|
|
4
|
|
38
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
117
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
1422
|
use JSON; |
|
4
|
|
|
|
|
18753
|
|
|
4
|
|
|
|
|
28
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
WWW::Session::Serialization::JSON - Serialization engine for WWW::Session with JSON backend |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
JSON serialization engine for WWW::Session objects |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.10 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This module handles serialization for WWW::Session objects |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The object implements two main methods : serialize() and expand() |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use WWW::Session::Serialization::JSON; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $serializer = WWW::Session::Serialization::JSON->new(); |
35
|
|
|
|
|
|
|
... |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$string = $serializer->serialize($structure); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
... |
40
|
|
|
|
|
|
|
$structure = $serializer->expand($string); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 new |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Creates a new WWW::Session::Serialization::JSON object |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Usage : |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $serializer = WWW::Session::Serialization::JSON->new(); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
No arguments required. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub new { |
57
|
6
|
|
|
6
|
1
|
876
|
my $class = shift; |
58
|
|
|
|
|
|
|
|
59
|
6
|
|
|
|
|
15
|
my $self = {}; |
60
|
|
|
|
|
|
|
|
61
|
6
|
|
|
|
|
25
|
bless $self,$class; |
62
|
|
|
|
|
|
|
|
63
|
6
|
|
|
|
|
18
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 serialize |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Serializes a structure and returns a string containing all the data |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub serialize { |
73
|
16
|
|
|
16
|
1
|
39
|
my ($self,$data) = @_; |
74
|
|
|
|
|
|
|
|
75
|
16
|
|
|
|
|
69
|
return to_json($data); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 expand |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Deserializes string and returns a structure containing all the data |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
sub expand { |
85
|
6
|
|
|
6
|
1
|
1611
|
my ($self,$string) = @_; |
86
|
|
|
|
|
|
|
|
87
|
6
|
|
|
|
|
24
|
return from_json($string); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Gligan Calin Horea, C<< >> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 BUGS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
97
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
98
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SUPPORT |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
perldoc WWW::Session::Serialization::JSON |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
You can also look for information at: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over 4 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * CPAN Ratings |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * Search CPAN |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Copyright 2012 Gligan Calin Horea. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
141
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
142
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; # End of WWW::Session::Serialization::JSON |