1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<!-- NewPage --> 3<html lang="en"> 4<head> 5<!-- Generated by javadoc (version 1.7.0_25) on Mon Jun 02 17:48:54 PDT 2014 --> 6<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> 7<title>JsonSerializer (jackson-databind 2.4.0 API)</title> 8<meta name="date" content="2014-06-02"> 9<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> 10</head> 11<body> 12<script type="text/javascript"><!-- 13 if (location.href.indexOf('is-external=true') == -1) { 14 parent.document.title="JsonSerializer (jackson-databind 2.4.0 API)"; 15 } 16//--> 17</script> 18<noscript> 19<div>JavaScript is disabled on your browser.</div> 20</noscript> 21<!-- ========= START OF TOP NAVBAR ======= --> 22<div class="topNav"><a name="navbar_top"> 23<!-- --> 24</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> 25<!-- --> 26</a> 27<ul class="navList" title="Navigation"> 28<li><a href="../../../../overview-summary.html">Overview</a></li> 29<li><a href="package-summary.html">Package</a></li> 30<li class="navBarCell1Rev">Class</li> 31<li><a href="class-use/JsonSerializer.html">Use</a></li> 32<li><a href="package-tree.html">Tree</a></li> 33<li><a href="../../../../deprecated-list.html">Deprecated</a></li> 34<li><a href="../../../../index-all.html">Index</a></li> 35<li><a href="../../../../help-doc.html">Help</a></li> 36</ul> 37</div> 38<div class="subNav"> 39<ul class="navList"> 40<li><a href="../../../../com/fasterxml/jackson/databind/JsonSerializable.html" title="interface in com.fasterxml.jackson.databind"><span class="strong">Prev Class</span></a></li> 41<li><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.None.html" title="class in com.fasterxml.jackson.databind"><span class="strong">Next Class</span></a></li> 42</ul> 43<ul class="navList"> 44<li><a href="../../../../index.html?com/fasterxml/jackson/databind/JsonSerializer.html" target="_top">Frames</a></li> 45<li><a href="JsonSerializer.html" target="_top">No Frames</a></li> 46</ul> 47<ul class="navList" id="allclasses_navbar_top"> 48<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> 49</ul> 50<div> 51<script type="text/javascript"><!-- 52 allClassesLink = document.getElementById("allclasses_navbar_top"); 53 if(window==top) { 54 allClassesLink.style.display = "block"; 55 } 56 else { 57 allClassesLink.style.display = "none"; 58 } 59 //--> 60</script> 61</div> 62<div> 63<ul class="subNavList"> 64<li>Summary: </li> 65<li><a href="#nested_class_summary">Nested</a> | </li> 66<li>Field | </li> 67<li><a href="#constructor_summary">Constr</a> | </li> 68<li><a href="#method_summary">Method</a></li> 69</ul> 70<ul class="subNavList"> 71<li>Detail: </li> 72<li>Field | </li> 73<li><a href="#constructor_detail">Constr</a> | </li> 74<li><a href="#method_detail">Method</a></li> 75</ul> 76</div> 77<a name="skip-navbar_top"> 78<!-- --> 79</a></div> 80<!-- ========= END OF TOP NAVBAR ========= --> 81<!-- ======== START OF CLASS DATA ======== --> 82<div class="header"> 83<div class="subTitle">com.fasterxml.jackson.databind</div> 84<h2 title="Class JsonSerializer" class="title">Class JsonSerializer<T></h2> 85</div> 86<div class="contentContainer"> 87<ul class="inheritance"> 88<li><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li> 89<li> 90<ul class="inheritance"> 91<li>com.fasterxml.jackson.databind.JsonSerializer<T></li> 92</ul> 93</li> 94</ul> 95<div class="description"> 96<ul class="blockList"> 97<li class="blockList"> 98<dl> 99<dt>All Implemented Interfaces:</dt> 100<dd><a href="../../../../com/fasterxml/jackson/databind/jsonFormatVisitors/JsonFormatVisitable.html" title="interface in com.fasterxml.jackson.databind.jsonFormatVisitors">JsonFormatVisitable</a></dd> 101</dl> 102<dl> 103<dt>Direct Known Subclasses:</dt> 104<dd><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.None.html" title="class in com.fasterxml.jackson.databind">JsonSerializer.None</a>, <a href="../../../../com/fasterxml/jackson/databind/ser/std/StdSerializer.html" title="class in com.fasterxml.jackson.databind.ser.std">StdSerializer</a>, <a href="../../../../com/fasterxml/jackson/databind/ser/impl/TypeWrappedSerializer.html" title="class in com.fasterxml.jackson.databind.ser.impl">TypeWrappedSerializer</a></dd> 105</dl> 106<hr> 107<br> 108<pre>public abstract class <span class="strong">JsonSerializer<T></span> 109extends <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a> 110implements <a href="../../../../com/fasterxml/jackson/databind/jsonFormatVisitors/JsonFormatVisitable.html" title="interface in com.fasterxml.jackson.databind.jsonFormatVisitors">JsonFormatVisitable</a></pre> 111<div class="block">Abstract class that defines API used by <a href="../../../../com/fasterxml/jackson/databind/ObjectMapper.html" title="class in com.fasterxml.jackson.databind"><code>ObjectMapper</code></a> (and 112 other chained <a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind"><code>JsonSerializer</code></a>s too) to serialize Objects of 113 arbitrary types into JSON, using provided <a href="http://fasterxml.github.com/jackson-core/javadoc/2.4/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core"><code>JsonGenerator</code></a>. 114 <a href="../../../../com/fasterxml/jackson/databind/ser/std/StdSerializer.html" title="class in com.fasterxml.jackson.databind.ser.std"><code>StdSerializer</code></a> instead 115 of this class, since it will implement many of optional 116 methods of this class. 117<p> 118 NOTE: various <code>serialize</code> methods are never (to be) called 119 with null values -- caller <b>must</b> handle null values, usually 120 by calling <a href="../../../../com/fasterxml/jackson/databind/SerializerProvider.html#findNullValueSerializer(com.fasterxml.jackson.databind.BeanProperty)"><code>SerializerProvider.findNullValueSerializer(com.fasterxml.jackson.databind.BeanProperty)</code></a> to obtain 121 serializer to use. 122 This also means that custom serializers can not be directly used to change 123 the output to produce when serializing null values. 124<p> 125 If serializer is an aggregate one -- meaning it delegates handling of some 126 of its contents by using other serializer(s) -- it typically also needs 127 to implement <a href="../../../../com/fasterxml/jackson/databind/ser/ResolvableSerializer.html" title="interface in com.fasterxml.jackson.databind.ser"><code>ResolvableSerializer</code></a>, 128 which can locate secondary serializers needed. This is important to allow dynamic 129 overrides of serializers; separate call interface is needed to separate 130 resolution of secondary serializers (which may have cyclic link back 131 to serializer itself, directly or indirectly). 132<p> 133 In addition, to support per-property annotations (to configure aspects 134 of serialization on per-property basis), serializers may want 135 to implement 136 <a href="../../../../com/fasterxml/jackson/databind/ser/ContextualSerializer.html" title="interface in com.fasterxml.jackson.databind.ser"><code>ContextualSerializer</code></a>, 137 which allows specialization of serializers: call to 138 <a href="../../../../com/fasterxml/jackson/databind/ser/ContextualSerializer.html#createContextual(com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.BeanProperty)"><code>ContextualSerializer.createContextual(com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.BeanProperty)</code></a> 139 is passed information on property, and can create a newly configured 140 serializer for handling that particular property. 141<p> 142 If both 143 <a href="../../../../com/fasterxml/jackson/databind/ser/ResolvableSerializer.html" title="interface in com.fasterxml.jackson.databind.ser"><code>ResolvableSerializer</code></a> and 144 <a href="../../../../com/fasterxml/jackson/databind/ser/ContextualSerializer.html" title="interface in com.fasterxml.jackson.databind.ser"><code>ContextualSerializer</code></a> 145 are implemented, resolution of serializers occurs before 146 contextualization.</div> 147</li> 148</ul> 149</div> 150<div class="summary"> 151<ul class="blockList"> 152<li class="blockList"> 153<!-- ======== NESTED CLASS SUMMARY ======== --> 154<ul class="blockList"> 155<li class="blockList"><a name="nested_class_summary"> 156<!-- --> 157</a> 158<h3>Nested Class Summary</h3> 159<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation"> 160<caption><span>Nested Classes</span><span class="tabEnd"> </span></caption> 161<tr> 162<th class="colFirst" scope="col">Modifier and Type</th> 163<th class="colLast" scope="col">Class and Description</th> 164</tr> 165<tr class="altColor"> 166<td class="colFirst"><code>static class </code></td> 167<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.None.html" title="class in com.fasterxml.jackson.databind">JsonSerializer.None</a></strong></code> 168<div class="block">This marker class is only to be used with annotations, to 169 indicate that <b>no serializer is configured</b>.</div> 170</td> 171</tr> 172</table> 173</li> 174</ul> 175<!-- ======== CONSTRUCTOR SUMMARY ======== --> 176<ul class="blockList"> 177<li class="blockList"><a name="constructor_summary"> 178<!-- --> 179</a> 180<h3>Constructor Summary</h3> 181<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> 182<caption><span>Constructors</span><span class="tabEnd"> </span></caption> 183<tr> 184<th class="colOne" scope="col">Constructor and Description</th> 185</tr> 186<tr class="altColor"> 187<td class="colOne"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#JsonSerializer()">JsonSerializer</a></strong>()</code> </td> 188</tr> 189</table> 190</li> 191</ul> 192<!-- ========== METHOD SUMMARY =========== --> 193<ul class="blockList"> 194<li class="blockList"><a name="method_summary"> 195<!-- --> 196</a> 197<h3>Method Summary</h3> 198<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> 199<caption><span>Methods</span><span class="tabEnd"> </span></caption> 200<tr> 201<th class="colFirst" scope="col">Modifier and Type</th> 202<th class="colLast" scope="col">Method and Description</th> 203</tr> 204<tr class="altColor"> 205<td class="colFirst"><code>void</code></td> 206<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#acceptJsonFormatVisitor(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, com.fasterxml.jackson.databind.JavaType)">acceptJsonFormatVisitor</a></strong>(<a href="../../../../com/fasterxml/jackson/databind/jsonFormatVisitors/JsonFormatVisitorWrapper.html" title="interface in com.fasterxml.jackson.databind.jsonFormatVisitors">JsonFormatVisitorWrapper</a> visitor, 207 <a href="../../../../com/fasterxml/jackson/databind/JavaType.html" title="class in com.fasterxml.jackson.databind">JavaType</a> type)</code> 208<div class="block">Default implementation simply calls <a href="../../../../com/fasterxml/jackson/databind/jsonFormatVisitors/JsonFormatVisitorWrapper.html#expectAnyFormat(com.fasterxml.jackson.databind.JavaType)"><code>JsonFormatVisitorWrapper.expectAnyFormat(JavaType)</code></a>.</div> 209</td> 210</tr> 211<tr class="rowColor"> 212<td class="colFirst"><code><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind">JsonSerializer</a><?></code></td> 213<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#getDelegatee()">getDelegatee</a></strong>()</code> 214<div class="block">Accessor that can be used to determine if this serializer uses 215 another serializer for actual serialization, by delegating 216 calls.</div> 217</td> 218</tr> 219<tr class="altColor"> 220<td class="colFirst"><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a><<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a>></code></td> 221<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#handledType()">handledType</a></strong>()</code> 222<div class="block">Method for accessing type of Objects this serializer can handle.</div> 223</td> 224</tr> 225<tr class="rowColor"> 226<td class="colFirst"><code>boolean</code></td> 227<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#isEmpty(T)">isEmpty</a></strong>(<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a> value)</code> 228<div class="block">Method called to check whether given serializable value is 229 considered "empty" value (for purposes of suppressing serialization 230 of empty values).</div> 231</td> 232</tr> 233<tr class="altColor"> 234<td class="colFirst"><code>boolean</code></td> 235<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#isUnwrappingSerializer()">isUnwrappingSerializer</a></strong>()</code> 236<div class="block">Accessor for checking whether this serializer is an 237 "unwrapping" serializer; this is necessary to know since 238 it may also require caller to suppress writing of the 239 leading property name.</div> 240</td> 241</tr> 242<tr class="rowColor"> 243<td class="colFirst"><code><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind">JsonSerializer</a><<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a>></code></td> 244<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#replaceDelegatee(com.fasterxml.jackson.databind.JsonSerializer)">replaceDelegatee</a></strong>(<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind">JsonSerializer</a><?> delegatee)</code> 245<div class="block">Method that can be called to try to replace serializer this serializer 246 delegates calls to.</div> 247</td> 248</tr> 249<tr class="altColor"> 250<td class="colFirst"><code>abstract void</code></td> 251<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#serialize(T, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)">serialize</a></strong>(<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a> value, 252 <a href="http://fasterxml.github.com/jackson-core/javadoc/2.4/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonGenerator</a> jgen, 253 <a href="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</a> provider)</code> 254<div class="block">Method that can be called to ask implementation to serialize 255 values of type this serializer handles.</div> 256</td> 257</tr> 258<tr class="rowColor"> 259<td class="colFirst"><code>void</code></td> 260<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#serializeWithType(T, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer)">serializeWithType</a></strong>(<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a> value, 261 <a href="http://fasterxml.github.com/jackson-core/javadoc/2.4/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonGenerator</a> jgen, 262 <a href="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</a> provider, 263 <a href="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html" title="class in com.fasterxml.jackson.databind.jsontype">TypeSerializer</a> typeSer)</code> 264<div class="block">Method that can be called to ask implementation to serialize 265 values of type this serializer handles, using specified type serializer 266 for embedding necessary type information.</div> 267</td> 268</tr> 269<tr class="altColor"> 270<td class="colFirst"><code><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind">JsonSerializer</a><<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a>></code></td> 271<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#unwrappingSerializer(com.fasterxml.jackson.databind.util.NameTransformer)">unwrappingSerializer</a></strong>(<a href="../../../../com/fasterxml/jackson/databind/util/NameTransformer.html" title="class in com.fasterxml.jackson.databind.util">NameTransformer</a> unwrapper)</code> 272<div class="block">Method that will return serializer instance that produces 273 "unwrapped" serialization, if applicable for type being 274 serialized (which is the case for some serializers 275 that produce JSON Objects as output).</div> 276</td> 277</tr> 278<tr class="rowColor"> 279<td class="colFirst"><code>boolean</code></td> 280<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html#usesObjectId()">usesObjectId</a></strong>()</code> 281<div class="block">Method that can be called to see whether this serializer instance 282 will use Object Id to handle cyclic references.</div> 283</td> 284</tr> 285</table> 286<ul class="blockList"> 287<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object"> 288<!-- --> 289</a> 290<h3>Methods inherited from class java.lang.<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3> 291<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</a></code></li> 292</ul> 293</li> 294</ul> 295</li> 296</ul> 297</div> 298<div class="details"> 299<ul class="blockList"> 300<li class="blockList"> 301<!-- ========= CONSTRUCTOR DETAIL ======== --> 302<ul class="blockList"> 303<li class="blockList"><a name="constructor_detail"> 304<!-- --> 305</a> 306<h3>Constructor Detail</h3> 307<a name="JsonSerializer()"> 308<!-- --> 309</a> 310<ul class="blockListLast"> 311<li class="blockList"> 312<h4>JsonSerializer</h4> 313<pre>public JsonSerializer()</pre> 314</li> 315</ul> 316</li> 317</ul> 318<!-- ============ METHOD DETAIL ========== --> 319<ul class="blockList"> 320<li class="blockList"><a name="method_detail"> 321<!-- --> 322</a> 323<h3>Method Detail</h3> 324<a name="unwrappingSerializer(com.fasterxml.jackson.databind.util.NameTransformer)"> 325<!-- --> 326</a> 327<ul class="blockList"> 328<li class="blockList"> 329<h4>unwrappingSerializer</h4> 330<pre>public <a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind">JsonSerializer</a><<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a>> unwrappingSerializer(<a href="../../../../com/fasterxml/jackson/databind/util/NameTransformer.html" title="class in com.fasterxml.jackson.databind.util">NameTransformer</a> unwrapper)</pre> 331<div class="block">Method that will return serializer instance that produces 332 "unwrapped" serialization, if applicable for type being 333 serialized (which is the case for some serializers 334 that produce JSON Objects as output). 335 If no unwrapped serializer can be constructed, will simply 336 return serializer as-is. 337<p> 338 Default implementation just returns serializer as-is, 339 indicating that no unwrapped variant exists</div> 340<dl><dt><span class="strong">Parameters:</span></dt><dd><code>unwrapper</code> - Name transformation to use to convert between names 341 of unwrapper properties</dd></dl> 342</li> 343</ul> 344<a name="replaceDelegatee(com.fasterxml.jackson.databind.JsonSerializer)"> 345<!-- --> 346</a> 347<ul class="blockList"> 348<li class="blockList"> 349<h4>replaceDelegatee</h4> 350<pre>public <a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind">JsonSerializer</a><<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a>> replaceDelegatee(<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind">JsonSerializer</a><?> delegatee)</pre> 351<div class="block">Method that can be called to try to replace serializer this serializer 352 delegates calls to. If not supported (either this serializer does not 353 delegate anything; or it does not want any changes), should either 354 throw <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/UnsupportedOperationException.html?is-external=true" title="class or interface in java.lang"><code>UnsupportedOperationException</code></a> (if operation does not 355 make sense or is not allowed); or return this serializer as is.</div> 356<dl><dt><span class="strong">Since:</span></dt> 357 <dd>2.1</dd></dl> 358</li> 359</ul> 360<a name="serialize(java.lang.Object,com.fasterxml.jackson.core.JsonGenerator,com.fasterxml.jackson.databind.SerializerProvider)"> 361<!-- --> 362</a><a name="serialize(T, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)"> 363<!-- --> 364</a> 365<ul class="blockList"> 366<li class="blockList"> 367<h4>serialize</h4> 368<pre>public abstract void serialize(<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a> value, 369 <a href="http://fasterxml.github.com/jackson-core/javadoc/2.4/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonGenerator</a> jgen, 370 <a href="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</a> provider) 371 throws <a href="http://docs.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a>, 372 <a href="http://fasterxml.github.com/jackson-core/javadoc/2.4/com/fasterxml/jackson/core/JsonProcessingException.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonProcessingException</a></pre> 373<div class="block">Method that can be called to ask implementation to serialize 374 values of type this serializer handles.</div> 375<dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - Value to serialize; can <b>not</b> be null.</dd><dd><code>jgen</code> - Generator used to output resulting Json content</dd><dd><code>provider</code> - Provider that can be used to get serializers for 376 serializing Objects value contains, if any.</dd> 377<dt><span class="strong">Throws:</span></dt> 378<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code></dd> 379<dd><code><a href="http://fasterxml.github.com/jackson-core/javadoc/2.4/com/fasterxml/jackson/core/JsonProcessingException.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonProcessingException</a></code></dd></dl> 380</li> 381</ul> 382<a name="serializeWithType(java.lang.Object,com.fasterxml.jackson.core.JsonGenerator,com.fasterxml.jackson.databind.SerializerProvider,com.fasterxml.jackson.databind.jsontype.TypeSerializer)"> 383<!-- --> 384</a><a name="serializeWithType(T, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer)"> 385<!-- --> 386</a> 387<ul class="blockList"> 388<li class="blockList"> 389<h4>serializeWithType</h4> 390<pre>public void serializeWithType(<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a> value, 391 <a href="http://fasterxml.github.com/jackson-core/javadoc/2.4/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonGenerator</a> jgen, 392 <a href="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</a> provider, 393 <a href="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html" title="class in com.fasterxml.jackson.databind.jsontype">TypeSerializer</a> typeSer) 394 throws <a href="http://docs.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a>, 395 <a href="http://fasterxml.github.com/jackson-core/javadoc/2.4/com/fasterxml/jackson/core/JsonProcessingException.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonProcessingException</a></pre> 396<div class="block">Method that can be called to ask implementation to serialize 397 values of type this serializer handles, using specified type serializer 398 for embedding necessary type information. 399<p> 400 Default implementation will throw <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/UnsupportedOperationException.html?is-external=true" title="class or interface in java.lang"><code>UnsupportedOperationException</code></a> 401 to indicate that proper type handling needs to be implemented. 402<p> 403 For simple datatypes written as a single scalar value (JSON String, Number, Boolean), 404 implementation would look like: 405<pre> 406 // note: method to call depends on whether this type is serialized as JSON scalar, object or Array! 407 typeSer.writeTypePrefixForScalar(value, jgen); 408 serialize(value, jgen, provider); 409 typeSer.writeTypeSuffixForScalar(value, jgen); 410</pre> 411 and implementations for type serialized as JSON Arrays or Objects would differ slightly, 412 as <code>START-ARRAY>/<code>END-ARRAY</code> and 413 <code>START-OBJECT>/<code>END-OBJECT</code> pairs 414 need to be properly handled with respect to serializing of contents.</div> 415<dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - Value to serialize; can <b>not</b> be null.</dd><dd><code>jgen</code> - Generator used to output resulting Json content</dd><dd><code>provider</code> - Provider that can be used to get serializers for 416 serializing Objects value contains, if any.</dd><dd><code>typeSer</code> - Type serializer to use for including type information</dd> 417<dt><span class="strong">Throws:</span></dt> 418<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code></dd> 419<dd><code><a href="http://fasterxml.github.com/jackson-core/javadoc/2.4/com/fasterxml/jackson/core/JsonProcessingException.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonProcessingException</a></code></dd></dl> 420</li> 421</ul> 422<a name="handledType()"> 423<!-- --> 424</a> 425<ul class="blockList"> 426<li class="blockList"> 427<h4>handledType</h4> 428<pre>public <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a><<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a>> handledType()</pre> 429<div class="block">Method for accessing type of Objects this serializer can handle. 430 Note that this information is not guaranteed to be exact -- it 431 may be a more generic (super-type) -- but it should not be 432 incorrect (return a non-related type). 433<p> 434 Default implementation will return null, which essentially means 435 same as returning <code>Object.class</code> would; that is, that 436 nothing is known about handled type. 437<p></div> 438</li> 439</ul> 440<a name="isEmpty(java.lang.Object)"> 441<!-- --> 442</a><a name="isEmpty(T)"> 443<!-- --> 444</a> 445<ul class="blockList"> 446<li class="blockList"> 447<h4>isEmpty</h4> 448<pre>public boolean isEmpty(<a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="type parameter in JsonSerializer">T</a> value)</pre> 449<div class="block">Method called to check whether given serializable value is 450 considered "empty" value (for purposes of suppressing serialization 451 of empty values). 452<p> 453 Default implementation will consider only null values to be empty.</div> 454<dl><dt><span class="strong">Since:</span></dt> 455 <dd>2.0</dd></dl> 456</li> 457</ul> 458<a name="usesObjectId()"> 459<!-- --> 460</a> 461<ul class="blockList"> 462<li class="blockList"> 463<h4>usesObjectId</h4> 464<pre>public boolean usesObjectId()</pre> 465<div class="block">Method that can be called to see whether this serializer instance 466 will use Object Id to handle cyclic references.</div> 467</li> 468</ul> 469<a name="isUnwrappingSerializer()"> 470<!-- --> 471</a> 472<ul class="blockList"> 473<li class="blockList"> 474<h4>isUnwrappingSerializer</h4> 475<pre>public boolean isUnwrappingSerializer()</pre> 476<div class="block">Accessor for checking whether this serializer is an 477 "unwrapping" serializer; this is necessary to know since 478 it may also require caller to suppress writing of the 479 leading property name.</div> 480</li> 481</ul> 482<a name="getDelegatee()"> 483<!-- --> 484</a> 485<ul class="blockList"> 486<li class="blockList"> 487<h4>getDelegatee</h4> 488<pre>public <a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind">JsonSerializer</a><?> getDelegatee()</pre> 489<div class="block">Accessor that can be used to determine if this serializer uses 490 another serializer for actual serialization, by delegating 491 calls. If so, will return immediate delegate (which itself may 492 delegate to further serializers); otherwise will return null.</div> 493<dl><dt><span class="strong">Returns:</span></dt><dd>Serializer this serializer delegates calls to, if null; 494 null otherwise.</dd><dt><span class="strong">Since:</span></dt> 495 <dd>2.1</dd></dl> 496</li> 497</ul> 498<a name="acceptJsonFormatVisitor(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, com.fasterxml.jackson.databind.JavaType)"> 499<!-- --> 500</a> 501<ul class="blockListLast"> 502<li class="blockList"> 503<h4>acceptJsonFormatVisitor</h4> 504<pre>public void acceptJsonFormatVisitor(<a href="../../../../com/fasterxml/jackson/databind/jsonFormatVisitors/JsonFormatVisitorWrapper.html" title="interface in com.fasterxml.jackson.databind.jsonFormatVisitors">JsonFormatVisitorWrapper</a> visitor, 505 <a href="../../../../com/fasterxml/jackson/databind/JavaType.html" title="class in com.fasterxml.jackson.databind">JavaType</a> type) 506 throws <a href="../../../../com/fasterxml/jackson/databind/JsonMappingException.html" title="class in com.fasterxml.jackson.databind">JsonMappingException</a></pre> 507<div class="block">Default implementation simply calls <a href="../../../../com/fasterxml/jackson/databind/jsonFormatVisitors/JsonFormatVisitorWrapper.html#expectAnyFormat(com.fasterxml.jackson.databind.JavaType)"><code>JsonFormatVisitorWrapper.expectAnyFormat(JavaType)</code></a>.</div> 508<dl> 509<dt><strong>Specified by:</strong></dt> 510<dd><code><a href="../../../../com/fasterxml/jackson/databind/jsonFormatVisitors/JsonFormatVisitable.html#acceptJsonFormatVisitor(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, com.fasterxml.jackson.databind.JavaType)">acceptJsonFormatVisitor</a></code> in interface <code><a href="../../../../com/fasterxml/jackson/databind/jsonFormatVisitors/JsonFormatVisitable.html" title="interface in com.fasterxml.jackson.databind.jsonFormatVisitors">JsonFormatVisitable</a></code></dd> 511<dd><code>type</code> - Type of element (entity like property) being visited</dd> 512<dt><span class="strong">Throws:</span></dt> 513<dd><code><a href="../../../../com/fasterxml/jackson/databind/JsonMappingException.html" title="class in com.fasterxml.jackson.databind">JsonMappingException</a></code></dd><dt><span class="strong">Since:</span></dt> 514 <dd>2.1</dd></dl> 515</li> 516</ul> 517</li> 518</ul> 519</li> 520</ul> 521</div> 522</div> 523<!-- ========= END OF CLASS DATA ========= --> 524<!-- ======= START OF BOTTOM NAVBAR ====== --> 525<div class="bottomNav"><a name="navbar_bottom"> 526<!-- --> 527</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> 528<!-- --> 529</a> 530<ul class="navList" title="Navigation"> 531<li><a href="../../../../overview-summary.html">Overview</a></li> 532<li><a href="package-summary.html">Package</a></li> 533<li class="navBarCell1Rev">Class</li> 534<li><a href="class-use/JsonSerializer.html">Use</a></li> 535<li><a href="package-tree.html">Tree</a></li> 536<li><a href="../../../../deprecated-list.html">Deprecated</a></li> 537<li><a href="../../../../index-all.html">Index</a></li> 538<li><a href="../../../../help-doc.html">Help</a></li> 539</ul> 540</div> 541<div class="subNav"> 542<ul class="navList"> 543<li><a href="../../../../com/fasterxml/jackson/databind/JsonSerializable.html" title="interface in com.fasterxml.jackson.databind"><span class="strong">Prev Class</span></a></li> 544<li><a href="../../../../com/fasterxml/jackson/databind/JsonSerializer.None.html" title="class in com.fasterxml.jackson.databind"><span class="strong">Next Class</span></a></li> 545</ul> 546<ul class="navList"> 547<li><a href="../../../../index.html?com/fasterxml/jackson/databind/JsonSerializer.html" target="_top">Frames</a></li> 548<li><a href="JsonSerializer.html" target="_top">No Frames</a></li> 549</ul> 550<ul class="navList" id="allclasses_navbar_bottom"> 551<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> 552</ul> 553<div> 554<script type="text/javascript"><!-- 555 allClassesLink = document.getElementById("allclasses_navbar_bottom"); 556 if(window==top) { 557 allClassesLink.style.display = "block"; 558 } 559 else { 560 allClassesLink.style.display = "none"; 561 } 562 //--> 563</script> 564</div> 565<div> 566<ul class="subNavList"> 567<li>Summary: </li> 568<li><a href="#nested_class_summary">Nested</a> | </li> 569<li>Field | </li> 570<li><a href="#constructor_summary">Constr</a> | </li> 571<li><a href="#method_summary">Method</a></li> 572</ul> 573<ul class="subNavList"> 574<li>Detail: </li> 575<li>Field | </li> 576<li><a href="#constructor_detail">Constr</a> | </li> 577<li><a href="#method_detail">Method</a></li> 578</ul> 579</div> 580<a name="skip-navbar_bottom"> 581<!-- --> 582</a></div> 583<!-- ======== END OF BOTTOM NAVBAR ======= --> 584<p class="legalCopy"><small>Copyright © 2014 <a href="http://fasterxml.com/">FasterXML</a>. All Rights Reserved.</small></p> 585</body> 586</html> 587