line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package WebService::Simple::Parser::JSON; |
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
3
|
use base qw(WebService::Simple::Parser); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
336
|
|
7
|
1
|
|
|
1
|
|
5
|
use JSON 2.0; |
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new |
10
|
|
|
|
|
|
|
{ |
11
|
1
|
|
|
1
|
1
|
1
|
my $class = shift; |
12
|
1
|
|
|
|
|
3
|
my %args = @_; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
33
|
|
|
24
|
my $json = delete $args{json} || JSON->new; |
15
|
1
|
|
|
|
|
7
|
my $self = $class->SUPER::new(%args); |
16
|
1
|
|
|
|
|
12
|
$self->{json} = $json; |
17
|
1
|
|
|
|
|
4
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub parse_response |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
23
|
0
|
|
|
|
|
|
my $content = $_[0]->decoded_content; |
24
|
|
|
|
|
|
|
# JSONP to pure JSON |
25
|
0
|
|
|
|
|
|
$content =~ s/[a-zA-Z_\$][a-zA-Z0-9_\$]*\s*\((.+)\)\s*;?\s*$/$1/; |
26
|
0
|
|
|
|
|
|
$self->{json}->decode( $content ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |