# GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoders.Optional

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_ActiveReports_Core_Rdl_Persistence_Json_JsonCoders_Optional_" data-uid="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoders.Optional*">Optional Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_ActiveReports_Core_Rdl_Persistence_Json_JsonCoders_Optional_" data-uid="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoders.Optional*"></a>
<h4 id="GrapeCity_ActiveReports_Core_Rdl_Persistence_Json_JsonCoders_Optional__1_GrapeCity_ActiveReports_Core_Rdl_Persistence_Json_JsonCoder___0____0_" data-uid="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoders.Optional``1(GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder{``0},``0)">Optional&lt;T&gt;(JsonCoder&lt;T&gt;, T)</h4>
<div class="markdown level1 summary"><p>Encodes the specified default value as undefined and skips it during serialization.
During deserialization, the undefined value will be replaced with the specified default value.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static JsonCoder&lt;T&gt; Optional&lt;T&gt;(JsonCoder&lt;T&gt; coder, T defValue)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder-1.html">JsonCoder</a>&lt;T&gt;</td>
      <td><span class="parametername">coder</span></td>
      <td><p>A <a class="xref" href="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder-1.html">JsonCoder&lt;T&gt;</a> to encode and decode the value.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">T</span></td>
      <td><span class="parametername">defValue</span></td>
      <td><p>The default value.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder-1.html">JsonCoder</a>&lt;T&gt;</td>
      <td><p>A <a class="xref" href="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder-1.html">JsonCoder&lt;T&gt;</a> with the default value handling.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td><p>The type of the value.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="GrapeCity_ActiveReports_Core_Rdl_Persistence_Json_JsonCoders_Optional_" data-uid="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoders.Optional*"></a>
<h4 id="GrapeCity_ActiveReports_Core_Rdl_Persistence_Json_JsonCoders_Optional__1_GrapeCity_ActiveReports_Core_Rdl_Persistence_Json_JsonCoder___0__" data-uid="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoders.Optional``1(GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder{``0})">Optional&lt;T&gt;(JsonCoder&lt;T&gt;)</h4>
<div class="markdown level1 summary"><p>Skips empty objects during serialization and deserializes undefined values as a default object.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static JsonCoder&lt;T&gt; Optional&lt;T&gt;(this JsonCoder&lt;T&gt; coder)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder-1.html">JsonCoder</a>&lt;T&gt;</td>
      <td><span class="parametername">coder</span></td>
      <td><p>A <a class="xref" href="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder-1.html">JsonCoder&lt;T&gt;</a> to encode and decode the value.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder-1.html">JsonCoder</a>&lt;T&gt;</td>
      <td><p>A <a class="xref" href="GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoder-1.html">JsonCoder&lt;T&gt;</a> that handles optional values.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td><p>The type of the object to be encoded and decoded.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
