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::JSON 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.


 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.


Sam Kington <>

The source code for this module is hosted on GitHub - 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.