Client/Formatter/JSON.pm

filter: Statementstmt 70.0% 14 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 2 / 2 totaltotal 70.3% 19 / 27 CC 1 SCAR 3.4
CC
1
Cov
70%
encode
2.0
decode
2.0
BEGIN
1.0
CRAP 1.4
« Client/Agent/Dump.pm ↑ Summary Client/Protocol.pm »
1 package Net::OpenSocial::Client::Formatter::JSON;
2  
3 1 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 with 'Net::OpenSocial::Client::Formatter';
5  
6 1 ▶use JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 has '+name' => (
9 default => q{json},
10 );
11  
12 1 has '+content_type' => (
13 default => q{application/json},
14 );
15  
16 0 ▶sub encode {
Subroutine encode: not called CC=1 SCAR=6.9
Pod documented
17 0 my ( $self, $obj ) = @_;
18 0 my $content = JSON::encode_json($obj);
19 0 return $content;
20 }
21  
22 0 ▶sub decode {
Subroutine decode: not called CC=1 SCAR=6.9
Pod documented
23 0 my ( $self, $content ) = @_;
24 0 my $obj = JSON::decode_json($content);
25 0 return $obj;
26 }
27  
28 1 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 __PACKAGE__->meta->make_immutable;
30 1 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, E<lt>lyo.kato@gmail.comE<gt>
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  
« Client/Agent/Dump.pm ↑ Summary Client/Protocol.pm »