| 1 | # $Id$ | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | package WebService::Simple::Parser::JSON; | ||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 3 | ▶ | use base qw(WebService::Simple::Parser); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 3 | ▶ | use JSON 2.0; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | sub new | ||||||||||||||||||||
| 10 | 4 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 11 | 4 | my $class = shift; | |||||||||||||||||||
| 12 | 4 | my %args = @_; | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 4 | ▶ | my $json = delete $args{json} || JSON->new; | ||||||||||||||||||
|
Condition33%1/3
delete $args{'json'} || 'JSON'->new
MC/DC0%0/2
delete $args{'json'} || 'JSON'->new
delete $args{'json'}
'JSON'->new
Truth table33%1/3
A || B
A= delete $args{'json'}B= 'JSON'->new
| |||||||||||||||||||||
| 15 | 4 | my $self = $class->SUPER::new(%args); | |||||||||||||||||||
| 16 | 4 | $self->{json} = $json; | |||||||||||||||||||
| 17 | 4 | return $self; | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | sub parse_request | ||||||||||||||||||||
| 21 | 2 | ▶ | { | ||||||||||||||||||
|
Subroutine
parse_request: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 22 | 2 | my $self = shift; | |||||||||||||||||||
| 23 | # my $content = $_[0]->decoded_content; | ||||||||||||||||||||
| 24 | # # JSONP to pure JSON | ||||||||||||||||||||
| 25 | # $content =~ s/[a-zA-Z_\$][a-zA-Z0-9_\$]*\s*\((.+)\)\s*;?\s*$/$1/; | ||||||||||||||||||||
| 26 | 2 | $self->{json}->encode( $_[0] ); | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | sub parse_response | ||||||||||||||||||||
| 30 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
parse_response: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 31 | 0 | my $self = shift; | |||||||||||||||||||
| 32 | 0 | my $content = $_[0]->decoded_content; | |||||||||||||||||||
| 33 | # JSONP to pure JSON | ||||||||||||||||||||
| 34 | 0 | $content =~ s/[a-zA-Z_\$][a-zA-Z0-9_\$]*\s*\((.+)\)\s*;?\s*$/$1/; | |||||||||||||||||||
| 35 | 0 | $self->{json}->decode( $content ); | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 3 | 1; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | __END__ | ||||||||||||||||||||