Parser::JSON;
use strict;
use warnings;
use base qw(WebService::Simple::Parser);
use JSON 2.0;
sub new
{
my $class = shift;
my %args = @_;
my $json = delete $args{json} || JSON->new;
ER::new(%args);
$self->{json} = $json;
return $self;
}
sub parse_request
{
my $self = shift;
# my $content = $_[0]->decoded_content;
# # JSONP to pure JSON
# $content =~ s/[a-zA-Z_\
.+)\)\s*;?\s*$/$1/;
$self->{json}->encode( $_[0] );
}
sub parse_response
{
my $self = shift;
my $content = $_[0]->decoded_content;
# JSONP to pure JSON
$content =~ s/[a-zA-Z_\$][a
$debug;
if($self->{content_type} && $self->{content_type} eq 'application/json'){
$self->__init_request_parser_json();
}else{
$self->{request_parser} = sub { return \$_[0] };
}
_parser_json {
my $self = shift;
require WebService::Simple::Parser::JSON;
my $json_parser = WebService::Simple::Parser::JSON->new();
$self->{request_parser_json} = sub { $json_parser-
params" go: form-urlencoded -> $uri / json/xml -> $content
my ($uri,$response);
if( ($self->{content_type} && $self->{content_type} eq 'application/json') || ($headers{'Content-Type'} && $h