NAME

LWP::UserAgent::JSON - a subclass of LWP::UserAgent that understands JSON

SYNOPSIS

my $user_agent = LWP::UserAgent::JSON->new;
my $request    = HTTP::Request::JSON->new(...);
my $response   = $user_agent->request($request);
# $response->isa('HTTP::Response::JSON') if we got back JSON

DESCRIPTION

This is a simple subclass of LWP::UserAgent which recognises if it gets JSON output back, and if so returns an HTTP::Response::JSON object instead of a HTTP::Response object. It exposes the logic of reblessing the HTTP::Response object in case you get handed a HTTP::Response object by some other method.

simple_request

As LWP::UserAgent::simple_request, but returns a HTTP::Response:JSON object instead of a HTTP::Response object if the response is JSON.

rebless_maybe

In: $response
Out: $reblessed

Supplied with a HTTP::Response object, looks to see if it's a JSON object, and if so reblesses it to be a HTTP::Response::JSON object. Returns whether it reblessed the object or not.

AUTHOR

Sam Kington <skington@cpan.org>

The source code for this module is hosted on GitHub https://github.com/skington/lwp-json-tiny - this is probably the best place to look for suggestions and feedback.

COPYRIGHT

Copyright (c) 2015 Sam Kington.

LICENSE

This library is free software and may be distributed under the same terms as perl itself.