rAgent::JSON;
use strict;
use warnings;
no warnings 'uninitialized';
use HTTP::Request::JSON;
use LWP::JSON::Tiny;
use Scalar::Util ();
use parent 'LWP::UserAgent';
our $VERSION = $LWP::JSON::Tiny:
AME
LWP::UserAgent::JSON - a subclass of LWP::UserAgent that understands JSON
=head1 SYNOPSIS
my $user_agent = LWP::UserAgent::JSON->new;
my $request = HTTP::Request::JSON->new(...);
my $resp
P::Response::JSON') if we got back JSON
=head1 DESCRIPTION
This is a subclass of LWP::UserAgent which recognises if it gets
JSON output back, and if so returns an L<HTTP::Response::JSON> object inst
quest::JSON;
use strict;
use warnings;
no warnings 'uninitialized';
use parent 'HTTP::Message::JSON', 'HTTP::Request';
our $VERSION = $LWP::JSON::Tiny::VERSION;
use Encode ();
use LWP::JSON::Tiny;
SON::MaybeXS ();
=head1 NAME
HTTP::Request::JSON - a subclass of HTTP::Request that understands JSON
=head1 SYNOPSIS
my $request = HTTP::Request::JSON->new(PATCH => "$base_url/death_ray");
# $re
t's OK to send JSON back
$request->json_content(
{
self_destruct_mechanism => 'disabled',
users_allowed_to_override => [],
}
);
# Request content is JSON-encoded, and
P::Response::JSON;
use strict;
use warnings;
no warnings 'uninitialized';
use LWP::JSON::Tiny;
use parent 'HTTP::Message::JSON', 'HTTP::Response';
use Encode;
our $VERSION = $LWP::JSON::Tiny::VERS
TP::Response::JSON - a subclass of HTTP::Response that understands JSON
=head1 SYNOPSIS
if ($response->isa('HTTP::Response::JSON')) {
Your::Own::Code::do_something($response->json_content);
}
ple subclass of HTTP::Response that implements a method
L</json_content> which returns the JSON-decoded contents of the response.
=head2 json_content
Out: $perl_data
Returns the Perl data structur
TP::Message::JSON;
use strict;
use warnings;
no warnings 'uninitialized';
our $VERSION = $LWP::JSON::Tiny::VERSION;
=head1 NAME
HTTP::Message::JSON - a very simple superclass for JSON HTTP message
s
=head1 DESCRIPTION
This is a very simple superclass used by HTTP::Request::JSON and
HTTP::Response::JSON. It overrides the default behaviour of the HTTP::Headers
method content_is_text.
=head2 co
nt type application/json.
Otherwise uses the default behaviour of HTTP::Headers.
=cut
sub content_is_text {
my ($self) = @_;
if ($self->content_type eq 'application/json') {
return
package LWP::JSON::Tiny;
use strict;
use warnings;
no warnings 'uninitialized';
use HTTP::Request::JSON;
use HTTP::Response::JSON;
use JSON::MaybeXS;
use LWP;
use LWP::UserAgent::JSON;
# Have you u
E
LWP::JSON::Tiny - use JSON natively with LWP objects
=head1 VERSION
This is version 0.014.
=head1 SYNOPSIS
my $user_agent = LWP::UserAgent::JSON->new;
my $request = HTTP::Request::JSON->new(P
x/upload_dance");
$request->json_content({ contents => [qw(badger mushroom snake)] });
my $response = $user_agent->request($request);
if (my $upload_id = $response->json_content->{upload}{id}) {