| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::OpenSocial::Client::Formatter::JSON; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use Any::Moose; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
|
|
with 'Net::OpenSocial::Client::Formatter'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1325
|
use JSON (); |
|
|
1
|
|
|
|
|
13511
|
|
|
|
1
|
|
|
|
|
133
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has '+name' => ( |
|
9
|
|
|
|
|
|
|
default => q{json}, |
|
10
|
|
|
|
|
|
|
); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has '+content_type' => ( |
|
13
|
|
|
|
|
|
|
default => q{application/json}, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub encode { |
|
17
|
0
|
|
|
0
|
1
|
|
my ( $self, $obj ) = @_; |
|
18
|
0
|
|
|
|
|
|
my $content = JSON::encode_json($obj); |
|
19
|
0
|
|
|
|
|
|
return $content; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub decode { |
|
23
|
0
|
|
|
0
|
1
|
|
my ( $self, $content ) = @_; |
|
24
|
0
|
|
|
|
|
|
my $obj = JSON::decode_json($content); |
|
25
|
0
|
|
|
|
|
|
return $obj; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
10
|
no Any::Moose; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
11
|
|
|
29
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
30
|
|
|
|
|
|
|
1; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Net::OpenSocial::Client::Formatter::JSON - JSON formatter |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $formatter = Net::OpenSocial::Client::Formatter::JSON->new; |
|
39
|
|
|
|
|
|
|
my $request_content = $formatter->encode( $request_obj ); |
|
40
|
|
|
|
|
|
|
... |
|
41
|
|
|
|
|
|
|
my $response_obj = $formatter->decode( $response_content ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
JSON formatter |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 METHODS |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 content_type |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Mime type for the format. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 name |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Formatter name |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 encode |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Encode perl object to a formatted JSON string. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 decode |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Decode JSON formatted string to perl object. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Lyo Kato, Elyo.kato@gmail.comE |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Copyright (C) 2009 by Lyo Kato |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
74
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
|
75
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
|
78
|
|
|
|
|
|
|
|