t::HTTP::API::Parser::JSON;
BEGIN {
$Net::HTTP::API::Parser::JSON::VERSION = '0.14';
}
# ABSTRACT: Parse JSON
use JSON;
use Moose;
extends 'Net::HTTP::API::Parser';
has _json_parser => (
is
=> 'rw',
isa => 'JSON',
lazy => 1,
default => sub { JSON->new->allow_nonref },
);
sub encode {
my ($self, $content) = @_;
$self->_json_parser->encode($content);
}
sub
e {
my ($self, $content) = @_;
$self->_json_parser->decode($content);
}
1;
__END__
=pod
=head1 NAME
Net::HTTP::API::Parser::JSON - Parse JSON
=head1 VERSION
version 0.14
=head1 SYNOPSI
oose::Role;
use Moose::Util::TypeConstraints;
sub content_type {
{ json => {value => 'application/json', module => 'JSON',},
yaml => {value => 'text/x-yaml', module => 'YAML'},
error
use Moose;
use JSON;
use Moose::Util::TypeConstraints;
use overload '""' => \&error;
subtype error => as 'Str';
coerce error => from 'HashRef' => via { JSON::encode_json $_};
has http_error
::HTTP::API;
# we declare an API, the base_url is http://exemple.com/api
# the format is json and it will be append to the query
# You can set api_base_url later, calling $obj->api_base_u
lare my_api => (
api_base_url => 'http://exemple.com/api',
api_format => 'json',
api_format_mode => 'append',
);
# declaring a users method
# calling $obj-
net_api_declare backtype => (
base_url => 'http://api....',
format => 'json',
format_mode => 'append',
);
=over 2
=item B<api_base_url>
The base url for all t