The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<html><head><title>LWP::JSON::Tiny</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='#VERSION'>VERSION</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='#Class_methods'>Class methods</a>
    <ul   class='indexList indexList3'>
      <li class='indexItem indexItem3'><a href='#json_object'>json_object</a>
      <li class='indexItem indexItem3'><a href='#default_json_arguments'>default_json_arguments</a>
    </ul>
  </ul>
  <li class='indexItem indexItem1'><a href='#SEE_ALSO'>SEE ALSO</a>
  <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::JSON::Tiny - use JSON natively with LWP objects</p>

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

<p>This is version 0.014.</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(POST =&#62; &#34;$url_prefix/upload_dance&#34;);
 $request-&#62;json_content({ contents =&#62; [qw(badger mushroom snake)] });
 my $response = $user_agent-&#62;request($request);
 if (my $upload_id = $response-&#62;json_content-&#62;{upload}{id}) {
     print &#34;Uploaded Weebl rip-off: $upload_id\n&#34;;
 }

 my $other_response = $some_other_object-&#62;do_stuff(...);
 if (LWP::UserAgent::JSON-&#62;rebless_maybe($other_response)) {
     do_something($other_response-&#62;json_content);
 }</pre>

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

<p>A lot of RESTful API integration involves pointless busy work with setting accept and content-type headers, remembering how Unicode is supposed to work and so on. This is a very simple wrapper around HTTP::Request and HTTP::Response that handles all of that for you.</p>

<p>There are four classes in this distribution:</p>

<dl>
<dt><a name="LWP::JSON::Tiny"
>LWP::JSON::Tiny</a></dt>

<dd>
<p>Pulls in the other classes, and implements a <a href="#json_object" class="podlinkpod"
>&#34;json_object&#34;</a> method which returns a JSON object, suitable for parsing and emitting JSON.</p>

<dt><a name="HTTP::Request::JSON"
>HTTP::Request::JSON</a></dt>

<dd>
<p>A subclass of HTTP::Request. It automatically sets the Accept header to <code>application/json</code>, and implements a <a href="http://search.cpan.org/perldoc?HTTP%3A%3ARequest%3A%3AJSON#json_content" class="podlinkpod"
>json_content</a> method which takes a JSONable data structure and sets the content-type.</p>

<dt><a name="HTTP::Response::JSON"
>HTTP::Response::JSON</a></dt>

<dd>
<p>A subclass of HTTP::Response. It implements a <a href="http://search.cpan.org/perldoc?HTTP%3A%3AResponse%3A%3AJSON#json_content" class="podlinkpod"
>json_content</a> method which decodes the JSON contents into a Perl data structure.</p>

<dt><a name="LWP::UserAgent::JSON"
>LWP::UserAgent::JSON</a></dt>

<dd>
<p>A subclass of LWP::UserAgent. It does only one thing: is a response has content-type JSON, it reblesses it into a HTTP::Response::JSON object. It exposes this method <a href="http://search.cpan.org/perldoc?LWP%3A%3AUserAgent%3A%3AJSON#rebless_maybe" class="podlinkpod"
>rebless_maybe</a> for convenience, if you ever get an HTTP::Response object back from some other class.</p>
</dd>
</dl>

<p>As befits a ::Tiny distribution, sensible defaults are applied. If you really need to tweak this stuff (e.g. you really care about the very slight performance impact of sorting all hash keys), look at the individual modules&#39; documentation for how you can subclass behaviour.</p>

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

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

<pre> Out: $json</pre>

<p>Returns a JSON object, as per JSON::MaybeXS-&#62;new. Cached across multiple calls for speed.</p>

<p>Note that the JSON object has the utf8 option disabled. <i>This is deliberate</i>. The documentation for JSON::XS is very clear that the utf8 option means both that it should spit out JSON in UTF8, and that it should expect strings passed to it to be in UTF8 encoding. This latter part is daft, and violates the best practice that character encoding should be dealt with at the outermost layer.</p>

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

<pre> Out: %default_json_arguments</pre>

<p>The default arguments to pass to JSON::MaybeXS-&#62;new. This is what you&#39;d subclass if you wanted to change how LWP::JSON::Tiny encoded JSON.</p>

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

<p><a href="http://search.cpan.org/perldoc?JSON%3A%3AAPI" class="podlinkpod"
>JSON::API</a> handles authentication and common URL prefixes, but (a) doesn&#39;t support PATCH routes, and (b) makes you use a wrapper object rather than LWP directly.</p>

<p><a href="http://search.cpan.org/perldoc?WWW%3A%3AJSON" class="podlinkpod"
>WWW::JSON</a> handles authentication (including favours of OAuth), common URL prefixes, response data structure transformations, but has the same limitations as JSON::API, as well as being potentially unwieldy.</p>

<p><a href="http://search.cpan.org/perldoc?LWP%3A%3ASimple%3A%3AREST" class="podlinkpod"
>LWP::Simple::REST</a> decodes JSON but makes you use a wrapper object, and looks like a half-hearted attempt that never went anywhere.</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-2018 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>