<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Module: Utopia::Controller::Respond::Converter::ToJSON
  
    &mdash; Documentation by YARD 0.9.18
  
</title>

  <link rel="stylesheet" href="../../../../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../../../../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  pathId = "Utopia::Controller::Respond::Converter::ToJSON";
  relpath = '../../../../';
</script>


  <script type="text/javascript" charset="utf-8" src="../../../../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../../../../js/app.js"></script>


  </head>
  <body>
    <div class="nav_wrap">
      <iframe id="nav" src="../../../../class_list.html?1"></iframe>
      <div id="resizer"></div>
    </div>

    <div id="main" tabindex="-1">
      <div id="header">
        <div id="menu">
  
    <a href="../../../../_index.html">Index (T)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../../../Utopia.html" title="Utopia (module)">Utopia</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../../Controller.html" title="Utopia::Controller (class)">Controller</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Respond.html" title="Utopia::Controller::Respond (module)">Respond</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Converter.html" title="Utopia::Controller::Respond::Converter (module)">Converter</a></span></span>
     &raquo; 
    <span class="title">ToJSON</span>
  
</div>

        <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../../../../class_list.html">

        <svg width="24" height="24">
          <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
        </svg>
    </a>
  
</div>
        <div class="clear"></div>
      </div>

      <div id="content"><h1>Module: Utopia::Controller::Respond::Converter::ToJSON
  
  
  
</h1>
<div class="box_info">
  

  
  
  
  
  

  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/utopia/controller/respond.rb</dd>
  </dl>
  
</div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>To accept incoming requests with content-type JSON (e.g. POST with JSON data), consider using <code>Rack::PostBodyContentTypeParser</code>.</p>


  </div>
</div>
<div class="tags">
  

</div>
  
    <h2>
      Constant Summary
      <small><a href="#" class="constants_summary_toggle">collapse</a></small>
    </h2>

    <dl class="constants">
      
        <dt id="APPLICATION_JSON-constant" class="">APPLICATION_JSON =
          
        </dt>
        <dd><pre class="code"><span class='const'><span class='object_link'><a href="../../../HTTP.html" title="Utopia::HTTP (module)">HTTP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../../HTTP.html#Accept-constant" title="Utopia::HTTP::Accept (constant)">Accept</a></span></span><span class='op'>::</span><span class='const'>ContentType</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>application/json</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>charset:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>utf-8</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
      
        <dt id="HEADERS-constant" class="">HEADERS =
          
        </dt>
        <dd><pre class="code"><span class='lbrace'>{</span><span class='const'><span class='object_link'><a href="../../../HTTP.html" title="Utopia::HTTP (module)">HTTP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../../HTTP.html#CONTENT_TYPE-constant" title="Utopia::HTTP::CONTENT_TYPE (constant)">CONTENT_TYPE</a></span></span> <span class='op'>=&gt;</span> <span class='const'><span class='object_link'><a href="#APPLICATION_JSON-constant" title="Utopia::Controller::Respond::Converter::ToJSON::APPLICATION_JSON (constant)">APPLICATION_JSON</a></span></span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
      
    </dl>
  







  
    <h2>
      Class Method Summary
      <small><a href="#" class="summary_toggle">collapse</a></small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#call-class_method" title="call (class method)">.<strong>call</strong>(context, response, media_range)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#content_type-class_method" title="content_type (class method)">.<strong>content_type</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#serialize-class_method" title="serialize (class method)">.<strong>serialize</strong>(content, media_range)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#split-class_method" title="split (class method)">.<strong>split</strong>(*args)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
</div></span>
  
</li>

      
    </ul>
  



  <div id="class_method_details" class="method_details_list">
    <h2>Class Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="call-class_method">
  
    .<strong>call</strong>(context, response, media_range)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


88
89
90
91
92</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/utopia/controller/respond.rb', line 88</span>

<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_context'>context</span><span class='comma'>,</span> <span class='id identifier rubyid_response'>response</span><span class='comma'>,</span> <span class='id identifier rubyid_media_range'>media_range</span><span class='rparen'>)</span>
	<span class='const'><span class='object_link'><a href="../Converter.html" title="Utopia::Controller::Respond::Converter (module)">Converter</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update_response'><span class='object_link'><a href="../Converter.html#update_response-class_method" title="Utopia::Controller::Respond::Converter.update_response (method)">update_response</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="#HEADERS-constant" title="Utopia::Controller::Respond::Converter::ToJSON::HEADERS (constant)">HEADERS</a></span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_content'>content</span><span class='op'>|</span>
		<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_media_range'>media_range</span><span class='rparen'>)</span>
	<span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="content_type-class_method">
  
    .<strong>content_type</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


70
71
72</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/utopia/controller/respond.rb', line 70</span>

<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_content_type'>content_type</span>
	<span class='const'><span class='object_link'><a href="#APPLICATION_JSON-constant" title="Utopia::Controller::Respond::Converter::ToJSON::APPLICATION_JSON (constant)">APPLICATION_JSON</a></span></span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="serialize-class_method">
  
    .<strong>serialize</strong>(content, media_range)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


78
79
80
81
82
83
84
85
86</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/utopia/controller/respond.rb', line 78</span>

<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_media_range'>media_range</span><span class='rparen'>)</span>
	<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
	
	<span class='kw'>if</span> <span class='id identifier rubyid_version'>version</span> <span class='op'>=</span> <span class='id identifier rubyid_media_range'>media_range</span><span class='period'>.</span><span class='id identifier rubyid_parameters'>parameters</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>version</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
		<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:version</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_version'>version</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
	<span class='kw'>end</span>
	
	<span class='kw'>return</span> <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="split-class_method">
  
    .<strong>split</strong>(*args)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


74
75
76</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/utopia/controller/respond.rb', line 74</span>

<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
	<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_content_type'>content_type</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

      <div id="footer">
  Generated on Sat Mar  9 12:01:52 2019 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.9.18 (ruby-2.6.1).
</div>

    </div>
  </body>
</html>