LWP-JSON-Tiny

 view release on metacpan or  search on metacpan

docs/LWP-JSON-Tiny.html  view on Meta::CPAN

   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 a...

<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_mayb...
>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 ...

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

<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"



( run in 0.745 second using v1.01-cache-2.11-cpan-39bf76dae61 )