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_79) on Tue Jan 23 20:10:06 PST 2018 --> 6<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7<title>JsonInclude (Jackson-annotations 2.9.0 API)</title> 8<meta name="date" content="2018-01-23"> 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="JsonInclude (Jackson-annotations 2.9.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="../../../../com/fasterxml/jackson/annotation/package-summary.html">Package</a></li> 29<li class="navBarCell1Rev">Class</li> 30<li><a href="class-use/JsonInclude.html">Use</a></li> 31<li><a href="package-tree.html">Tree</a></li> 32<li><a href="../../../../deprecated-list.html">Deprecated</a></li> 33<li><a href="../../../../index-all.html">Index</a></li> 34<li><a href="../../../../help-doc.html">Help</a></li> 35</ul> 36</div> 37<div class="subNav"> 38<ul class="navList"> 39<li><a href="../../../../com/fasterxml/jackson/annotation/JsonIgnoreType.html" title="annotation in com.fasterxml.jackson.annotation"><span class="strong">Prev Class</span></a></li> 40<li><a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html" title="enum in com.fasterxml.jackson.annotation"><span class="strong">Next Class</span></a></li> 41</ul> 42<ul class="navList"> 43<li><a href="../../../../index.html?com/fasterxml/jackson/annotation/JsonInclude.html" target="_top">Frames</a></li> 44<li><a href="JsonInclude.html" target="_top">No Frames</a></li> 45</ul> 46<ul class="navList" id="allclasses_navbar_top"> 47<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> 48</ul> 49<div> 50<script type="text/javascript"><!-- 51 allClassesLink = document.getElementById("allclasses_navbar_top"); 52 if(window==top) { 53 allClassesLink.style.display = "block"; 54 } 55 else { 56 allClassesLink.style.display = "none"; 57 } 58 //--> 59</script> 60</div> 61<div> 62<ul class="subNavList"> 63<li>Summary: </li> 64<li>Required | </li> 65<li><a href="#annotation_type_optional_element_summary">Optional</a></li> 66</ul> 67<ul class="subNavList"> 68<li>Detail: </li> 69<li><a href="#annotation_type_element_detail">Element</a></li> 70</ul> 71</div> 72<a name="skip-navbar_top"> 73<!-- --> 74</a></div> 75<!-- ========= END OF TOP NAVBAR ========= --> 76<!-- ======== START OF CLASS DATA ======== --> 77<div class="header"> 78<div class="subTitle">com.fasterxml.jackson.annotation</div> 79<h2 title="Annotation Type JsonInclude" class="title">Annotation Type JsonInclude</h2> 80</div> 81<div class="contentContainer"> 82<div class="description"> 83<ul class="blockList"> 84<li class="blockList"> 85<hr> 86<br> 87<pre><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/Target.html?is-external=true" title="class or interface in java.lang.annotation">@Target</a>(<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/Target.html?is-external=true#value()" title="class or interface in java.lang.annotation">value</a>={<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/ElementType.html?is-external=true#ANNOTATION_TYPE" title="class or interface in java.lang.annotation">ANNOTATION_TYPE</a>,<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/ElementType.html?is-external=true#METHOD" title="class or interface in java.lang.annotation">METHOD</a>,<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/ElementType.html?is-external=true#FIELD" title="class or interface in java.lang.annotation">FIELD</a>,<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/ElementType.html?is-external=true#TYPE" title="class or interface in java.lang.annotation">TYPE</a>,<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/ElementType.html?is-external=true#PARAMETER" title="class or interface in java.lang.annotation">PARAMETER</a>}) 88<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/Retention.html?is-external=true" title="class or interface in java.lang.annotation">@Retention</a>(<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/Retention.html?is-external=true#value()" title="class or interface in java.lang.annotation">value</a>=<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/annotation/RetentionPolicy.html?is-external=true#RUNTIME" title="class or interface in java.lang.annotation">RUNTIME</a>) 89public @interface <span class="strong">JsonInclude</span></pre> 90<div class="block">Annotation used to indicate when value of the annotated property (when 91 used for a field, method or constructor parameter), or all 92 properties of the annotated class, is to be serialized. 93 Without annotation property values are always included, but by using 94 this annotation one can specify simple exclusion rules to reduce 95 amount of properties to write out. 96<p> 97 Note that the main inclusion criteria (one annotated with <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#value()"><code>value()</code></a>) 98 is checked on <b>Java object level</b>, for the annotated type, 99 and <b>NOT</b> on JSON output -- so even with <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#NON_NULL"><code>JsonInclude.Include.NON_NULL</code></a> 100 it is possible that JSON null values are output, if object reference 101 in question is not `null`. An example is <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicReference.html?is-external=true" title="class or interface in java.util.concurrent.atomic"><code>AtomicReference</code></a> 102 instance constructed to reference <code>null</code> value: such a value 103 would be serialized as JSON null, and not filtered out. 104<p> 105 To base inclusion on value of contained value(s), you will typically also need 106 to specify <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#content()"><code>content()</code></a> annotation; for example, specifying only 107 <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#value()"><code>value()</code></a> as <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#NON_EMPTY"><code>JsonInclude.Include.NON_EMPTY</code></a> for a {link java.util.Map} would 108 exclude <code>Map</code>s with no values, but would include <code>Map</code>s 109 with `null` values. To exclude Map with only `null` value, you would use both 110 annotations like so: 111<pre> 112public class Bean { 113 @JsonInclude(value=Include.NON_EMPTY, content=Include.NON_NULL) 114 public Map<String,String> entries; 115} 116</pre> 117 Similarly you could Maps that only contain 118 "empty" elements, or "non-default" values (see <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#NON_EMPTY"><code>JsonInclude.Include.NON_EMPTY</code></a> and 119 <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#NON_DEFAULT"><code>JsonInclude.Include.NON_DEFAULT</code></a> for more details). 120<p> 121 In addition to `Map`s, `content` concept is also supported for referential 122 types (like <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicReference.html?is-external=true" title="class or interface in java.util.concurrent.atomic"><code>AtomicReference</code></a>). 123 Note that `content` is NOT currently (as of Jackson 2.9) supported for 124 arrays or <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util"><code>Collection</code></a>s, but supported may be added in 125 future versions.</div> 126<dl><dt><span class="strong">Since:</span></dt> 127 <dd>2.0</dd></dl> 128</li> 129</ul> 130</div> 131<div class="summary"> 132<ul class="blockList"> 133<li class="blockList"> 134<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== --> 135<ul class="blockList"> 136<li class="blockList"><a name="annotation_type_optional_element_summary"> 137<!-- --> 138</a> 139<h3>Optional Element Summary</h3> 140<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation"> 141<caption><span>Optional Elements</span><span class="tabEnd"> </span></caption> 142<tr> 143<th class="colFirst" scope="col">Modifier and Type</th> 144<th class="colLast" scope="col">Optional Element and Description</th> 145</tr> 146<tr class="altColor"> 147<td class="colFirst"><code><a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html" title="enum in com.fasterxml.jackson.annotation">JsonInclude.Include</a></code></td> 148<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#content()">content</a></strong></code> 149<div class="block">Inclusion rule to use for entries ("content") of annotated 150 <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util"><code>Map</code></a>s and referential types (like 151 <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicReference.html?is-external=true" title="class or interface in java.util.concurrent.atomic"><code>AtomicReference</code></a>); 152 defaults to <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#ALWAYS"><code>JsonInclude.Include.ALWAYS</code></a>.</div> 153</td> 154</tr> 155<tr class="rowColor"> 156<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><?></code></td> 157<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#contentFilter()">contentFilter</a></strong></code> 158<div class="block">Specifies type of "Filter Object" to use in case 159 <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#content()"><code>content()</code></a> is <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#CUSTOM"><code>JsonInclude.Include.CUSTOM</code></a>: 160 if so, an instance is created by calling <code>HandlerInstantiator</code> 161 (of <code>ObjectMapper</code>), which by default simply calls 162 zero-argument constructor of the Filter Class.</div> 163</td> 164</tr> 165<tr class="altColor"> 166<td class="colFirst"><code><a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html" title="enum in com.fasterxml.jackson.annotation">JsonInclude.Include</a></code></td> 167<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#value()">value</a></strong></code> 168<div class="block">Inclusion rule to use for instances (values) of types (Classes) or 169 properties annotated; defaults to <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#ALWAYS"><code>JsonInclude.Include.ALWAYS</code></a>.</div> 170</td> 171</tr> 172<tr class="rowColor"> 173<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><?></code></td> 174<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#valueFilter()">valueFilter</a></strong></code> 175<div class="block">Specifies type of "Filter Object" to use in case 176 <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#value()"><code>value()</code></a> is <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#CUSTOM"><code>JsonInclude.Include.CUSTOM</code></a>: 177 if so, an instance is created by calling <code>HandlerInstantiator</code> 178 (of <code>ObjectMapper</code>), which by default simply calls 179 zero-argument constructor of the Filter Class.</div> 180</td> 181</tr> 182</table> 183</li> 184</ul> 185</li> 186</ul> 187</div> 188<div class="details"> 189<ul class="blockList"> 190<li class="blockList"> 191<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== --> 192<ul class="blockList"> 193<li class="blockList"><a name="annotation_type_element_detail"> 194<!-- --> 195</a> 196<h3>Element Detail</h3> 197<a name="value()"> 198<!-- --> 199</a> 200<ul class="blockList"> 201<li class="blockList"> 202<h4>value</h4> 203<pre>public abstract <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html" title="enum in com.fasterxml.jackson.annotation">JsonInclude.Include</a> value</pre> 204<div class="block">Inclusion rule to use for instances (values) of types (Classes) or 205 properties annotated; defaults to <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#ALWAYS"><code>JsonInclude.Include.ALWAYS</code></a>.</div> 206<dl> 207<dt>Default:</dt> 208<dd>com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS</dd> 209</dl> 210</li> 211</ul> 212<a name="content()"> 213<!-- --> 214</a> 215<ul class="blockList"> 216<li class="blockList"> 217<h4>content</h4> 218<pre>public abstract <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html" title="enum in com.fasterxml.jackson.annotation">JsonInclude.Include</a> content</pre> 219<div class="block">Inclusion rule to use for entries ("content") of annotated 220 <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util"><code>Map</code></a>s and referential types (like 221 <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicReference.html?is-external=true" title="class or interface in java.util.concurrent.atomic"><code>AtomicReference</code></a>); 222 defaults to <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#ALWAYS"><code>JsonInclude.Include.ALWAYS</code></a>.</div> 223<dl><dt><span class="strong">Since:</span></dt> 224 <dd>2.5</dd></dl> 225<dl> 226<dt>Default:</dt> 227<dd>com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS</dd> 228</dl> 229</li> 230</ul> 231<a name="valueFilter()"> 232<!-- --> 233</a> 234<ul class="blockList"> 235<li class="blockList"> 236<h4>valueFilter</h4> 237<pre>public abstract <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><?> valueFilter</pre> 238<div class="block">Specifies type of "Filter Object" to use in case 239 <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#value()"><code>value()</code></a> is <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#CUSTOM"><code>JsonInclude.Include.CUSTOM</code></a>: 240 if so, an instance is created by calling <code>HandlerInstantiator</code> 241 (of <code>ObjectMapper</code>), which by default simply calls 242 zero-argument constructor of the Filter Class.</div> 243<dl><dt><span class="strong">Since:</span></dt> 244 <dd>2.9</dd></dl> 245<dl> 246<dt>Default:</dt> 247<dd>java.lang.Void.class</dd> 248</dl> 249</li> 250</ul> 251<a name="contentFilter()"> 252<!-- --> 253</a> 254<ul class="blockListLast"> 255<li class="blockList"> 256<h4>contentFilter</h4> 257<pre>public abstract <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><?> contentFilter</pre> 258<div class="block">Specifies type of "Filter Object" to use in case 259 <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.html#content()"><code>content()</code></a> is <a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html#CUSTOM"><code>JsonInclude.Include.CUSTOM</code></a>: 260 if so, an instance is created by calling <code>HandlerInstantiator</code> 261 (of <code>ObjectMapper</code>), which by default simply calls 262 zero-argument constructor of the Filter Class.</div> 263<dl><dt><span class="strong">Since:</span></dt> 264 <dd>2.9</dd></dl> 265<dl> 266<dt>Default:</dt> 267<dd>java.lang.Void.class</dd> 268</dl> 269</li> 270</ul> 271</li> 272</ul> 273</li> 274</ul> 275</div> 276</div> 277<!-- ========= END OF CLASS DATA ========= --> 278<!-- ======= START OF BOTTOM NAVBAR ====== --> 279<div class="bottomNav"><a name="navbar_bottom"> 280<!-- --> 281</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> 282<!-- --> 283</a> 284<ul class="navList" title="Navigation"> 285<li><a href="../../../../com/fasterxml/jackson/annotation/package-summary.html">Package</a></li> 286<li class="navBarCell1Rev">Class</li> 287<li><a href="class-use/JsonInclude.html">Use</a></li> 288<li><a href="package-tree.html">Tree</a></li> 289<li><a href="../../../../deprecated-list.html">Deprecated</a></li> 290<li><a href="../../../../index-all.html">Index</a></li> 291<li><a href="../../../../help-doc.html">Help</a></li> 292</ul> 293</div> 294<div class="subNav"> 295<ul class="navList"> 296<li><a href="../../../../com/fasterxml/jackson/annotation/JsonIgnoreType.html" title="annotation in com.fasterxml.jackson.annotation"><span class="strong">Prev Class</span></a></li> 297<li><a href="../../../../com/fasterxml/jackson/annotation/JsonInclude.Include.html" title="enum in com.fasterxml.jackson.annotation"><span class="strong">Next Class</span></a></li> 298</ul> 299<ul class="navList"> 300<li><a href="../../../../index.html?com/fasterxml/jackson/annotation/JsonInclude.html" target="_top">Frames</a></li> 301<li><a href="JsonInclude.html" target="_top">No Frames</a></li> 302</ul> 303<ul class="navList" id="allclasses_navbar_bottom"> 304<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> 305</ul> 306<div> 307<script type="text/javascript"><!-- 308 allClassesLink = document.getElementById("allclasses_navbar_bottom"); 309 if(window==top) { 310 allClassesLink.style.display = "block"; 311 } 312 else { 313 allClassesLink.style.display = "none"; 314 } 315 //--> 316</script> 317</div> 318<div> 319<ul class="subNavList"> 320<li>Summary: </li> 321<li>Required | </li> 322<li><a href="#annotation_type_optional_element_summary">Optional</a></li> 323</ul> 324<ul class="subNavList"> 325<li>Detail: </li> 326<li><a href="#annotation_type_element_detail">Element</a></li> 327</ul> 328</div> 329<a name="skip-navbar_bottom"> 330<!-- --> 331</a></div> 332<!-- ======== END OF BOTTOM NAVBAR ======= --> 333<p class="legalCopy"><small>Copyright © 2008–2018 <a href="http://fasterxml.com/">FasterXML</a>. All rights reserved.</small></p> 334</body> 335</html> 336