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