OAuth/Lite2/Formatter/JSON.pm

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 100% 35 / 35 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« OAuth/Lite2/Formatter/FormURLEncoded.pm ↑ Summary OAuth/Lite2/Server/Context.pm »
1 package OAuth::Lite2::Formatter::JSON;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use parent 'OAuth::Lite2::Formatter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 ▶use JSON::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 ▶sub name { "json" }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
12 63 ▶sub type { "application/json" };
Subroutine type: called CC=1 SCAR=0.0
Pod documented
13  
14 54 ▶sub format {
Subroutine format: called CC=1 SCAR=0.0
Pod documented
15 54 my ($self, $hash) = @_;
16 54 return JSON::XS->new->encode($hash);
17 }
18  
19 56 ▶sub parse {
Subroutine parse: called CC=1 SCAR=0.0
Pod documented
20 56 my ($self, $json) = @_;
21 56 return JSON::XS->new->decode($json);
22 }
23  
24 =head1 NAME
25  
26 OAuth::Lite2::Formatter::JSON - OAuth 2.0 JSON formatters store
27  
28 =head1 SYNOPSIS
29  
30 my $formatter = OAuth::Lite2::Formatter::JSON->new;
31 my $obj = $formatter->parse( $string );
32 $string = $formatter->format( $obj );
33  
34 =head1 DESCRIPTION
35  
36 OAuth 2.0 JSON formatter
37  
38 =head1 METHODS
39  
40 =head2 name
41  
42 Accessor for name of this format, "json".
43  
44 =head2 type
45  
46 Accessor for content-type of this format, "application/json".
47  
48 =head2 format( $json_object )
49  
50 my $json_string = $formatter->format( $obj );
51  
52 =head2 parse( $json_string )
53  
54 my $obj = $formatter->parse( $json_string );
55  
56 =head1 SEE ALSO
57  
58 L<OAuth::Lite2::Formatter>
59 L<OAuth::Lite2::Formatters>
60 L<OAuth::Lite2::Formatter::XML>
61 L<OAuth::Lite2::Formatter::FormURLEncoded>
62  
63 =head1 AUTHOR
64  
65 Lyo Kato, E<lt>lyo.kato@gmail.comE<gt>
66  
67 =head1 COPYRIGHT AND LICENSE
68  
69 Copyright (C) 2010 by Lyo Kato
70  
71 This library is free software; you can redistribute it and/or modify
72 it under the same terms as Perl itself, either Perl version 5.8.8 or,
73 at your option, any later version of Perl 5 you may have available.
74  
75 =cut
76  
77 8 1;
« OAuth/Lite2/Formatter/FormURLEncoded.pm ↑ Summary OAuth/Lite2/Server/Context.pm »