<html><head><title>LWP::UserAgent::JSON</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >

<style type="text/css">
 <!--/*--><![CDATA[/*><!--*/
BODY {
  background: white;
  color: black;
  font-family: arial,sans-serif;
  margin: 0;
  padding: 1ex;
}

A:link, A:visited {
  background: transparent;
  color: #006699;
}

A[href="#POD_ERRORS"] {
  background: transparent;
  color: #FF0000;
}

DIV {
  border-width: 0;
}

DT {
  margin-top: 1em;
  margin-left: 1em;
}

.pod { margin-right: 20ex; }

.pod PRE     {
  background: #eeeeee;
  border: 1px solid #888888;
  color: black;
  padding: 1em;
  white-space: pre;
}

.pod H1      {
  background: transparent;
  color: #006699;
  font-size: large;
}

.pod H1 A { text-decoration: none; }
.pod H2 A { text-decoration: none; }
.pod H3 A { text-decoration: none; }
.pod H4 A { text-decoration: none; }

.pod H2      {
  background: transparent;
  color: #006699;
  font-size: medium;
}

.pod H3      {
  background: transparent;
  color: #006699;
  font-size: medium;
  font-style: italic;
}

.pod H4      {
  background: transparent;
  color: #006699;
  font-size: medium;
  font-weight: normal;
}

.pod IMG     {
  vertical-align: top;
}

.pod .toc A  {
  text-decoration: none;
}

.pod .toc LI {
  line-height: 1.2em;
  list-style-type: none;
}

  /*]]>*/-->
</style>


</head>
<body class='pod'>
<!--
  generated by Pod::Simple::HTML v3.29,
  using Pod::Simple::PullParser v3.29,
  under Perl v5.022003 at Fri May 11 18:29:25 2018 GMT.

 If you want to change this HTML document, you probably shouldn't do that
   by changing it directly.  Instead, see about changing the calling options
   to Pod::Simple::HTML, and/or subclassing Pod::Simple::HTML,
   then reconverting this document from the Pod source.
   When in doubt, email the author of Pod::Simple::HTML for advice.
   See 'perldoc Pod::Simple::HTML' for more info.

-->

<!-- start doc -->
<a name='___top' class='dummyTopAnchor' ></a>

<div class='indexgroup'>
<ul   class='indexList indexList1'>
  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
  <li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
  <ul   class='indexList indexList2'>
    <li class='indexItem indexItem2'><a href='#post_json'>post_json</a>
    <ul   class='indexList indexList3'>
      <li class='indexItem indexItem3'><a href='#put_json'>put_json</a>
      <li class='indexItem indexItem3'><a href='#patch_json'>patch_json</a>
      <li class='indexItem indexItem3'><a href='#patch'>patch</a>
    </ul>
    <li class='indexItem indexItem2'><a href='#simple_request'>simple_request</a>
    <li class='indexItem indexItem2'><a href='#rebless_maybe'>rebless_maybe</a>
  </ul>
  <li class='indexItem indexItem1'><a href='#AUTHOR'>AUTHOR</a>
  <li class='indexItem indexItem1'><a href='#COPYRIGHT'>COPYRIGHT</a>
  <li class='indexItem indexItem1'><a href='#LICENSE'>LICENSE</a>
</ul>
</div>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>

<p>LWP::UserAgent::JSON - a subclass of LWP::UserAgent that understands JSON</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>

<pre> my $user_agent = LWP::UserAgent::JSON-&#62;new;
 my $request    = HTTP::Request::JSON-&#62;new(...);
 my $response   = $user_agent-&#62;request($request);
 # $response-&#62;isa(&#39;HTTP::Response::JSON&#39;) if we got back JSON</pre>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>

<p>This is a subclass of LWP::UserAgent which recognises if it gets JSON output back, and if so returns an <a href="http://search.cpan.org/perldoc?HTTP%3A%3AResponse%3A%3AJSON" class="podlinkpod"
>HTTP::Response::JSON</a> object instead of a <a href="http://search.cpan.org/perldoc?HTTP%3A%3AResponse" class="podlinkpod"
>HTTP::Response</a> object. It exposes the logic of reblessing the HTTP::Response object in case you get handed a HTTP::Response object by some other method.</p>

<p>It also offers a handful of convenience methods to directly convert parameters into JSON for POST, PUT and PATCH requests.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="post_json"
>post_json</a></h2>

<p>Like LWP::UserAgent::post, except for when it&#39;s called as <code>post_json($url, $form_ref, ...)</code>, in which case $form_ref is turned into JSON. Obviously if you specify Content-Type or Content in subsequent header arguments they&#39;ll take precedence.</p>

<h3><a class='u' href='#___top' title='click to go to top of document'
name="put_json"
>put_json</a></h3>

<p>A variant on LWP::UserAgent::put with the same transformations as post_json. This requires that your version of LWP supports PUT, i.e. you have LWP 6.00 or later.</p>

<h3><a class='u' href='#___top' title='click to go to top of document'
name="patch_json"
>patch_json</a></h3>

<p>As post_json and put_json, but generates a PATCH request instead. As put_json, you need a semi-modern version of LWP for this.</p>

<h3><a class='u' href='#___top' title='click to go to top of document'
name="patch"
>patch</a></h3>

<p>LWP::UserAgent doesn&#39;t actually implement a patch method, so it&#39;s defined here.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="simple_request"
>simple_request</a></h2>

<p>As LWP::UserAgent::simple_request, but returns a <a href="http://search.cpan.org/perldoc?HTTP%3A%3AResponse%3AJSON" class="podlinkpod"
>HTTP::Response:JSON</a> object instead of a <a href="http://search.cpan.org/perldoc?HTTP%3A%3AResponse" class="podlinkpod"
>HTTP::Response</a> object if the response is JSON.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="rebless_maybe"
>rebless_maybe</a></h2>

<pre> In: $object
 Out: $reblessed</pre>

<p>Supplied with a HTTP::Request or HTTP::Response object, looks to see if it&#39;s a JSON object, and if so reblesses it to be a HTTP::Request::JSON or HTTP::Response::JSON object respectively. Returns whether it reblessed the object or not.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="AUTHOR"
>AUTHOR</a></h1>

<p>Sam Kington &#60;skington@cpan.org&#62;</p>

<p>The source code for this module is hosted on GitHub <a href="https://github.com/skington/lwp-json-tiny" class="podlinkurl"
>https://github.com/skington/lwp-json-tiny</a> - this is probably the best place to look for suggestions and feedback.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="COPYRIGHT"
>COPYRIGHT</a></h1>

<p>Copyright (c) 2015 Sam Kington.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="LICENSE"
>LICENSE</a></h1>

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

<!-- end doc -->

</body></html>