<html><head><title>HTTP::Request::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='#new'>new</a>
<li class='indexItem indexItem2'><a href='#json_content'>json_content</a>
<li class='indexItem indexItem2'><a href='#json_object'>json_object</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>HTTP::Request::JSON - a subclass of HTTP::Request 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 $request = HTTP::Request::JSON->new(PATCH => "$base_url/death_ray");
# $request has an Accept header saying it's OK to send JSON back
$request->json_content(
{
self_destruct_mechanism => 'disabled',
users_allowed_to_override => [],
}
);
# Request content is JSON-encoded, and the content-type is set.</pre>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>
<p>This is a simple subclass of HTTP::Request that does two things. First of all, it sets the Accept header to <code>application/json</code> as soon as it's created. Secondly, it implements a <a href="#json_content" class="podlinkpod"
>"json_content"</a> method that adds the supplied data structure to the request, as JSON, or returns the current JSON contents as a Perl structure.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="new"
>new</a></h2>
<pre> In: ...
Out: $request</pre>
<p>As HTTP::Request->new, but also sets the Accept header.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="json_content"
>json_content</a></h2>
<pre> In: $perl_data (optional)
Out: $converted_content</pre>
<p>A mutator for the request's JSON contents.</p>
<p>As a setter, supplied with a valid JSON data structure, sets the request contents to be the JSON-encoded version of that data structure, and sets the Content-Type header to <code>application/json</code>. Will throw an exception if the data structure cannot be converted to JSON. Returns the resulting string contents.</p>
<p>All strings in $perl_data must be Unicode strings, or you will get encoding errors.</p>
<p>As a getter, decodes the request contents from JSON into a Perl structure, and returns the resulting data structure.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="json_object"
>json_object</a></h2>
<pre> Out: $json_object</pre>
<p>Returns an object that knows how to handle the <code>encode</code> and <code>decode</code> methods. By default whatever LWP::JSON::Tiny->json_object returns. This is what you'd subclass if you wanted to use some other kind of JSON object instead.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="AUTHOR"
>AUTHOR</a></h1>
<p>Sam Kington <skington@cpan.org></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>