File Coverage

blib/lib/OAuth/Lite2/Formatter/JSON.pm
Criterion Covered Total %
statement 15 21 71.4
branch n/a
condition n/a
subroutine 5 9 55.5
pod 4 4 100.0
total 24 34 70.5


line stmt bran cond sub pod time code
1             package OAuth::Lite2::Formatter::JSON;
2              
3 6     6   25 use strict;
  6         7  
  6         157  
4 6     6   22 use warnings;
  6         5  
  6         183  
5              
6 6     6   1088 use parent 'OAuth::Lite2::Formatter';
  6         631  
  6         38  
7              
8 6     6   3913 use JSON;
  6         59166  
  6         28  
9 6     6   2145 use Try::Tiny;
  6         4034  
  6         1032  
10              
11 0     0 1   sub name { "json" }
12 0     0 1   sub type { "application/json" };
13              
14             sub format {
15 0     0 1   my ($self, $hash) = @_;
16 0           return JSON->new->encode($hash);
17             }
18              
19             sub parse {
20 0     0 1   my ($self, $json) = @_;
21 0           return JSON->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
59             L
60             L
61             L
62              
63             =head1 AUTHOR
64              
65             Lyo Kato, Elyo.kato@gmail.comE
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             1;