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_55) on Thu Jan 01 15:31:15 PST 2015 --> 6<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> 7<title>JsonUnwrapped (Jackson-annotations 2.5.0 API)</title> 8<meta name="date" content="2015-01-01"> 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="JsonUnwrapped (Jackson-annotations 2.5.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/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="../../../../com/fasterxml/jackson/annotation/JsonTypeName.html" title="annotation in com.fasterxml.jackson.annotation"><span class="strong">Prev Class</span></a></li> 40<li><a href="../../../../com/fasterxml/jackson/annotation/JsonValue.html" title="annotation 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/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: </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 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://download.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://download.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://download.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://download.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://download.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://download.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://download.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://download.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://download.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 (can not unwrap JSON arrays using this 136 mechanism) 137 </li> 138 <li>Serialization is done using <code>BeanSerializer</code>, not a custom serializer 139 </li> 140 <li>No type information is added; if type information needs to be added, structure can 141 not be altered regardless of inclusion strategy; so annotation is basically ignored. 142 </li> 143 </ul></div> 144</li> 145</ul> 146</div> 147<div class="summary"> 148<ul class="blockList"> 149<li class="blockList"> 150<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== --> 151<ul class="blockList"> 152<li class="blockList"><a name="annotation_type_optional_element_summary"> 153<!-- --> 154</a> 155<h3>Optional Element Summary</h3> 156<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation"> 157<caption><span>Optional Elements</span><span class="tabEnd"> </span></caption> 158<tr> 159<th class="colFirst" scope="col">Modifier and Type</th> 160<th class="colLast" scope="col">Optional Element and Description</th> 161</tr> 162<tr class="altColor"> 163<td class="colFirst"><code>boolean</code></td> 164<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/annotation/JsonUnwrapped.html#enabled()">enabled</a></strong></code> 165<div class="block">Property that is usually only used when overriding (masking) annotations, 166 using mix-in annotations.</div> 167</td> 168</tr> 169<tr class="rowColor"> 170<td class="colFirst"><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> 171<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/annotation/JsonUnwrapped.html#prefix()">prefix</a></strong></code> 172<div class="block">Optional property that can be used to add prefix String to use in front 173 of names of properties that are unwrapped: this can be done for example to prevent 174 name collisions.</div> 175</td> 176</tr> 177<tr class="altColor"> 178<td class="colFirst"><code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> 179<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/annotation/JsonUnwrapped.html#suffix()">suffix</a></strong></code> 180<div class="block">Optional property that can be used to add suffix String to append at the end 181 of names of properties that are unwrapped: this can be done for example to prevent 182 name collisions.</div> 183</td> 184</tr> 185</table> 186</li> 187</ul> 188</li> 189</ul> 190</div> 191<div class="details"> 192<ul class="blockList"> 193<li class="blockList"> 194<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== --> 195<ul class="blockList"> 196<li class="blockList"><a name="annotation_type_element_detail"> 197<!-- --> 198</a> 199<h3>Element Detail</h3> 200<a name="enabled()"> 201<!-- --> 202</a> 203<ul class="blockList"> 204<li class="blockList"> 205<h4>enabled</h4> 206<pre>public abstract boolean enabled</pre> 207<div class="block">Property that is usually only used when overriding (masking) annotations, 208 using mix-in annotations. Otherwise default value of 'true' is fine, and 209 value need not be explicitly included.</div> 210<dl> 211<dt>Default:</dt> 212<dd>true</dd> 213</dl> 214</li> 215</ul> 216<a name="prefix()"> 217<!-- --> 218</a> 219<ul class="blockList"> 220<li class="blockList"> 221<h4>prefix</h4> 222<pre>public abstract <a href="http://download.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> prefix</pre> 223<div class="block">Optional property that can be used to add prefix String to use in front 224 of names of properties that are unwrapped: this can be done for example to prevent 225 name collisions.</div> 226<dl> 227<dt>Default:</dt> 228<dd>""</dd> 229</dl> 230</li> 231</ul> 232<a name="suffix()"> 233<!-- --> 234</a> 235<ul class="blockListLast"> 236<li class="blockList"> 237<h4>suffix</h4> 238<pre>public abstract <a href="http://download.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> suffix</pre> 239<div class="block">Optional property that can be used to add suffix String to append at the end 240 of names of properties that are unwrapped: this can be done for example to prevent 241 name collisions.</div> 242<dl> 243<dt>Default:</dt> 244<dd>""</dd> 245</dl> 246</li> 247</ul> 248</li> 249</ul> 250</li> 251</ul> 252</div> 253</div> 254<!-- ========= END OF CLASS DATA ========= --> 255<!-- ======= START OF BOTTOM NAVBAR ====== --> 256<div class="bottomNav"><a name="navbar_bottom"> 257<!-- --> 258</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> 259<!-- --> 260</a> 261<ul class="navList" title="Navigation"> 262<li><a href="../../../../com/fasterxml/jackson/annotation/package-summary.html">Package</a></li> 263<li class="navBarCell1Rev">Class</li> 264<li><a href="class-use/JsonUnwrapped.html">Use</a></li> 265<li><a href="package-tree.html">Tree</a></li> 266<li><a href="../../../../deprecated-list.html">Deprecated</a></li> 267<li><a href="../../../../index-all.html">Index</a></li> 268<li><a href="../../../../help-doc.html">Help</a></li> 269</ul> 270</div> 271<div class="subNav"> 272<ul class="navList"> 273<li><a href="../../../../com/fasterxml/jackson/annotation/JsonTypeName.html" title="annotation in com.fasterxml.jackson.annotation"><span class="strong">Prev Class</span></a></li> 274<li><a href="../../../../com/fasterxml/jackson/annotation/JsonValue.html" title="annotation in com.fasterxml.jackson.annotation"><span class="strong">Next Class</span></a></li> 275</ul> 276<ul class="navList"> 277<li><a href="../../../../index.html?com/fasterxml/jackson/annotation/JsonUnwrapped.html" target="_top">Frames</a></li> 278<li><a href="JsonUnwrapped.html" target="_top">No Frames</a></li> 279</ul> 280<ul class="navList" id="allclasses_navbar_bottom"> 281<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> 282</ul> 283<div> 284<script type="text/javascript"><!-- 285 allClassesLink = document.getElementById("allclasses_navbar_bottom"); 286 if(window==top) { 287 allClassesLink.style.display = "block"; 288 } 289 else { 290 allClassesLink.style.display = "none"; 291 } 292 //--> 293</script> 294</div> 295<div> 296<ul class="subNavList"> 297<li>Summary: </li> 298<li>Required | </li> 299<li><a href="#annotation_type_optional_element_summary">Optional</a></li> 300</ul> 301<ul class="subNavList"> 302<li>Detail: </li> 303<li><a href="#annotation_type_element_detail">Element</a></li> 304</ul> 305</div> 306<a name="skip-navbar_bottom"> 307<!-- --> 308</a></div> 309<!-- ======== END OF BOTTOM NAVBAR ======= --> 310<p class="legalCopy"><small>Copyright © 2014-2015 <a href="http://fasterxml.com/">FasterXML</a>. All Rights Reserved.</small></p> 311</body> 312</html> 313