| 1 | package HTTP::Entity::Parser::JSON; | ||||||||||
| 2 | |||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 5 | ▶ | use JSON::MaybeXS qw/decode_json/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 5 | ▶ | use Encode qw/encode_utf8/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | sub new { | ||||||||||
| 9 | 1 | ▶ | bless [''], $_[0]; | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 10 | } | ||||||||||
| 11 | |||||||||||
| 12 | sub add { | ||||||||||
| 13 | 7 | ▶ | my $self = shift; | ||||||||
|
Subroutine
add: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 14 | 7 | ▶ | if (defined $_[0]) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 7 | $self->[0] .= $_[0]; | |||||||||
| 16 | } | ||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | sub finalize { | ||||||||||
| 20 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
finalize: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 21 | |||||||||||
| 22 | 1 | my $p = decode_json($self->[0]); | |||||||||
| 23 | 1 | my @params; | |||||||||
| 24 | 1 | ▶ | if (ref $p eq 'HASH') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 1 | ▶ | while (my ($k, $v) = each %$p) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 5 | ▶ | if (ref $v) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 3 | push @params, encode_utf8($k), $v; | |||||||||
| 28 | } else { | ||||||||||
| 29 | 2 | push @params, encode_utf8($k), encode_utf8($v); | |||||||||
| 30 | } | ||||||||||
| 31 | } | ||||||||||
| 32 | } | ||||||||||
| 33 | 1 | return (\@params, []); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 5 | 1; | |||||||||
| 37 | |||||||||||
| 38 | __END__ | ||||||||||