LWP::UserAgent::JSON - a subclass of LWP::UserAgent that understands JSON
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
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.
As LWP::UserAgent::simple_request, but returns a HTTP::Response:JSON object instead of a HTTP::Response object if the response is JSON.
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.
Sam Kington <firstname.lastname@example.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 (c) 2015 Sam Kington.
This library is free software and may be distributed under the same terms as perl itself.
To install LWP::JSON::Tiny, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.