• 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 (version 1.7.0_10-ea) on Sun Jul 14 20:03:21 PDT 2013 -->
6<title>JsonUnwrapped (Jackson JSON Processor)</title>
7<meta name="date" content="2013-07-14">
8<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
9</head>
10<body>
11<script type="text/javascript"><!--
12    if (location.href.indexOf('is-external=true') == -1) {
13        parent.document.title="JsonUnwrapped (Jackson JSON Processor)";
14    }
15//-->
16</script>
17<noscript>
18<div>JavaScript is disabled on your browser.</div>
19</noscript>
20<!-- ========= START OF TOP NAVBAR ======= -->
21<div class="topNav"><a name="navbar_top">
22<!--   -->
23</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
24<!--   -->
25</a>
26<ul class="navList" title="Navigation">
27<li><a href="../../../../overview-summary.html">Overview</a></li>
28<li><a href="package-summary.html">Package</a></li>
29<li class="navBarCell1Rev">Class</li>
30<li><a href="class-use/JsonUnwrapped.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="../../../../org/codehaus/jackson/annotate/JsonTypeName.html" title="annotation in org.codehaus.jackson.annotate"><span class="strong">Prev Class</span></a></li>
40<li><a href="../../../../org/codehaus/jackson/annotate/JsonValue.html" title="annotation in org.codehaus.jackson.annotate"><span class="strong">Next Class</span></a></li>
41</ul>
42<ul class="navList">
43<li><a href="../../../../index.html?org/codehaus/jackson/annotate/JsonUnwrapped.html" target="_top">Frames</a></li>
44<li><a href="JsonUnwrapped.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:&nbsp;</li>
64<li>Required&nbsp;|&nbsp;</li>
65<li><a href="#annotation_type_optional_element_summary">Optional</a></li>
66</ul>
67<ul class="subNavList">
68<li>Detail:&nbsp;</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">org.codehaus.jackson.annotate</div>
79<h2 title="Annotation Type JsonUnwrapped" class="title">Annotation Type JsonUnwrapped</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#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#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#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">JsonUnwrapped</span></pre>
90<div class="block">Annotation used to indicate that a property should be serialized
91 "unwrapped"; that is, if it would be serialized as JSON Object, its
92 properties are instead included as properties of its containing
93 Object. For example, consider case of POJO like:
94
95<pre>
96  public class Parent {
97    public int age;
98    public Name name;
99  }
100  public class Name {
101    public String first, last;
102  }
103</pre>
104 which would normally be serialized as follows (assuming @JsonUnwrapped
105 had no effect):
106<pre>
107  {
108    "age" : 18,
109    "name" : {
110      "first" : "Joey",
111      "last" : "Sixpack"
112    }
113  }
114</pre>
115 can be changed to this:
116<pre>
117  {
118    "age" : 18,
119    "first" : "Joey",
120    "last" : "Sixpack"
121  }
122</pre>
123 by changing Parent class to:
124<pre>
125  public class Parent {
126    public int age;
127    \@JsonUnwrapped
128    public Name name;
129  }
130</pre>
131 Annotation can only be added to properties, and not classes, as it is contextual.
132<p>
133 Also note that annotation only applies if
134<ul>
135 <li>Value is serialized as JSON Object
136   </li>
137 <li>Serialization is done using <code>BeanSerializer</code>, not a custom serializer
138   </li>
139 <li>No type information is added; if type information needs to be added, structure can
140   not be altered regardless of inclusion strategy; so annotation is basically ignored.
141   </li>
142 </ul></div>
143<dl><dt><span class="strong">Since:</span></dt>
144  <dd>1.9</dd></dl>
145</li>
146</ul>
147</div>
148<div class="summary">
149<ul class="blockList">
150<li class="blockList">
151<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== -->
152<ul class="blockList">
153<li class="blockList"><a name="annotation_type_optional_element_summary">
154<!--   -->
155</a>
156<h3>Optional Element Summary</h3>
157<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation">
158<caption><span>Optional Elements</span><span class="tabEnd">&nbsp;</span></caption>
159<tr>
160<th class="colFirst" scope="col">Modifier and Type</th>
161<th class="colLast" scope="col">Optional Element and Description</th>
162</tr>
163<tr class="altColor">
164<td class="colFirst"><code>boolean</code></td>
165<td class="colLast"><code><strong><a href="../../../../org/codehaus/jackson/annotate/JsonUnwrapped.html#enabled()">enabled</a></strong></code>
166<div class="block">Property that is usually only used when overriding (masking) annotations,
167 using mix-in annotations.</div>
168</td>
169</tr>
170</table>
171</li>
172</ul>
173</li>
174</ul>
175</div>
176<div class="details">
177<ul class="blockList">
178<li class="blockList">
179<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->
180<ul class="blockList">
181<li class="blockList"><a name="annotation_type_element_detail">
182<!--   -->
183</a>
184<h3>Element Detail</h3>
185<a name="enabled()">
186<!--   -->
187</a>
188<ul class="blockListLast">
189<li class="blockList">
190<h4>enabled</h4>
191<pre>public abstract&nbsp;boolean&nbsp;enabled</pre>
192<div class="block">Property that is usually only used when overriding (masking) annotations,
193 using mix-in annotations. Otherwise default value of 'true' is fine, and
194 value need not be explicitly included.</div>
195<dl>
196<dt>Default:</dt>
197<dd>true</dd>
198</dl>
199</li>
200</ul>
201</li>
202</ul>
203</li>
204</ul>
205</div>
206</div>
207<!-- ========= END OF CLASS DATA ========= -->
208<!-- ======= START OF BOTTOM NAVBAR ====== -->
209<div class="bottomNav"><a name="navbar_bottom">
210<!--   -->
211</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
212<!--   -->
213</a>
214<ul class="navList" title="Navigation">
215<li><a href="../../../../overview-summary.html">Overview</a></li>
216<li><a href="package-summary.html">Package</a></li>
217<li class="navBarCell1Rev">Class</li>
218<li><a href="class-use/JsonUnwrapped.html">Use</a></li>
219<li><a href="package-tree.html">Tree</a></li>
220<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
221<li><a href="../../../../index-all.html">Index</a></li>
222<li><a href="../../../../help-doc.html">Help</a></li>
223</ul>
224</div>
225<div class="subNav">
226<ul class="navList">
227<li><a href="../../../../org/codehaus/jackson/annotate/JsonTypeName.html" title="annotation in org.codehaus.jackson.annotate"><span class="strong">Prev Class</span></a></li>
228<li><a href="../../../../org/codehaus/jackson/annotate/JsonValue.html" title="annotation in org.codehaus.jackson.annotate"><span class="strong">Next Class</span></a></li>
229</ul>
230<ul class="navList">
231<li><a href="../../../../index.html?org/codehaus/jackson/annotate/JsonUnwrapped.html" target="_top">Frames</a></li>
232<li><a href="JsonUnwrapped.html" target="_top">No Frames</a></li>
233</ul>
234<ul class="navList" id="allclasses_navbar_bottom">
235<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
236</ul>
237<div>
238<script type="text/javascript"><!--
239  allClassesLink = document.getElementById("allclasses_navbar_bottom");
240  if(window==top) {
241    allClassesLink.style.display = "block";
242  }
243  else {
244    allClassesLink.style.display = "none";
245  }
246  //-->
247</script>
248</div>
249<div>
250<ul class="subNavList">
251<li>Summary:&nbsp;</li>
252<li>Required&nbsp;|&nbsp;</li>
253<li><a href="#annotation_type_optional_element_summary">Optional</a></li>
254</ul>
255<ul class="subNavList">
256<li>Detail:&nbsp;</li>
257<li><a href="#annotation_type_element_detail">Element</a></li>
258</ul>
259</div>
260<a name="skip-navbar_bottom">
261<!--   -->
262</a></div>
263<!-- ======== END OF BOTTOM NAVBAR ======= -->
264</body>
265</html>
266