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>JsonProperty (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="JsonProperty (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/JsonProperty.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/JsonMerge.html" title="annotation in com.fasterxml.jackson.annotation"><span class="typeNameLink">Prev Class</span></a></li> 47<li><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.Access.html" title="enum in com.fasterxml.jackson.annotation"><span class="typeNameLink">Next Class</span></a></li> 48</ul> 49<ul class="navList"> 50<li><a href="../../../../index.html?com/fasterxml/jackson/annotation/JsonProperty.html" target="_top">Frames</a></li> 51<li><a href="JsonProperty.html" target="_top">No Frames</a></li> 52</ul> 53<ul class="navList" id="allclasses_navbar_top"> 54<li><a href="../../../../allclasses-noframe.html">All 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: </li> 71<li><a href="#annotation.type.field.summary">Field</a> | </li> 72<li>Required | </li> 73<li><a href="#annotation.type.optional.element.summary">Optional</a></li> 74</ul> 75<ul class="subNavList"> 76<li>Detail: </li> 77<li><a href="#annotation.type.field.detail">Field</a> | </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 JsonProperty" class="title">Annotation Type JsonProperty</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#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#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#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">JsonProperty</span></pre> 99<div class="block">Marker annotation that can be used to define a non-static 100 method as a "setter" or "getter" for a logical property 101 (depending on its signature), 102 or non-static object field to be used (serialized, deserialized) as 103 a logical property. 104<p> 105 Default value ("") indicates that the field name is used 106 as the property name without any modifications, but it 107 can be specified to non-empty value to specify different 108 name. Property name refers to name used externally, as 109 the field name in JSON objects. 110<p> 111 Starting with Jackson 2.6 this annotation may also be 112 used to change serialization of <code>Enum</code> like so: 113<pre> 114public enum MyEnum { 115 @JsonProperty("theFirstValue") THE_FIRST_VALUE, 116 @JsonProperty("another_value") ANOTHER_VALUE; 117} 118</pre> 119 as an alternative to using <a href="../../../../com/fasterxml/jackson/annotation/JsonValue.html" title="annotation in com.fasterxml.jackson.annotation"><code>JsonValue</code></a> annotation.</div> 120</li> 121</ul> 122</div> 123<div class="summary"> 124<ul class="blockList"> 125<li class="blockList"> 126<!-- =========== ANNOTATION TYPE FIELD SUMMARY =========== --> 127<ul class="blockList"> 128<li class="blockList"><a name="annotation.type.field.summary"> 129<!-- --> 130</a> 131<h3>Field Summary</h3> 132<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation"> 133<caption><span>Fields</span><span class="tabEnd"> </span></caption> 134<tr> 135<th class="colFirst" scope="col">Modifier and Type</th> 136<th class="colLast" scope="col">Fields and Description</th> 137</tr> 138<tr class="altColor"> 139<td class="colFirst"><code>static int</code></td> 140<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html#INDEX_UNKNOWN">INDEX_UNKNOWN</a></span></code> 141<div class="block">Marker value used to indicate that no index has been specified.</div> 142</td> 143</tr> 144<tr class="rowColor"> 145<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> 146<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html#USE_DEFAULT_NAME">USE_DEFAULT_NAME</a></span></code> 147<div class="block">Special value that indicates that handlers should use the default 148 name (derived from method or field name) for property.</div> 149</td> 150</tr> 151</table> 152</li> 153</ul> 154<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== --> 155<ul class="blockList"> 156<li class="blockList"><a name="annotation.type.optional.element.summary"> 157<!-- --> 158</a> 159<h3>Optional Element Summary</h3> 160<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation"> 161<caption><span>Optional Elements</span><span class="tabEnd"> </span></caption> 162<tr> 163<th class="colFirst" scope="col">Modifier and Type</th> 164<th class="colLast" scope="col">Optional Element and Description</th> 165</tr> 166<tr class="altColor"> 167<td class="colFirst"><code><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.Access.html" title="enum in com.fasterxml.jackson.annotation">JsonProperty.Access</a></code></td> 168<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html#access--">access</a></span></code> 169<div class="block">Optional property that may be used to change the way visibility of 170 accessors (getter, field-as-getter) and mutators (constructor parameter, 171 setter, field-as-setter) is determined, either so that otherwise 172 non-visible accessors (like private getters) may be used; or that 173 otherwise visible accessors are ignored.</div> 174</td> 175</tr> 176<tr class="rowColor"> 177<td class="colFirst"><code><a href="https://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> 178<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html#defaultValue--">defaultValue</a></span></code> 179<div class="block">Property that may be used to <b>document</b> expected default value 180 for the property: most often used as source information for generating 181 schemas (like JSON Schema or protobuf/thrift schema), or documentation.</div> 182</td> 183</tr> 184<tr class="altColor"> 185<td class="colFirst"><code>int</code></td> 186<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html#index--">index</a></span></code> 187<div class="block">Property that indicates numerical index of this property (relative 188 to other properties specified for the Object).</div> 189</td> 190</tr> 191<tr class="rowColor"> 192<td class="colFirst"><code>boolean</code></td> 193<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html#required--">required</a></span></code> 194<div class="block">Property that indicates whether a value (which may be explicit 195 null) is expected for property during deserialization or not.</div> 196</td> 197</tr> 198<tr class="altColor"> 199<td class="colFirst"><code><a href="https://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> 200<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html#value--">value</a></span></code> 201<div class="block">Defines name of the logical property, i.e.</div> 202</td> 203</tr> 204</table> 205</li> 206</ul> 207</li> 208</ul> 209</div> 210<div class="details"> 211<ul class="blockList"> 212<li class="blockList"> 213<!-- ============ ANNOTATION TYPE FIELD DETAIL =========== --> 214<ul class="blockList"> 215<li class="blockList"><a name="annotation.type.field.detail"> 216<!-- --> 217</a> 218<h3>Field Detail</h3> 219<a name="USE_DEFAULT_NAME"> 220<!-- --> 221</a> 222<ul class="blockList"> 223<li class="blockList"> 224<h4>USE_DEFAULT_NAME</h4> 225<pre>public static final <a href="https://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> USE_DEFAULT_NAME</pre> 226<div class="block">Special value that indicates that handlers should use the default 227 name (derived from method or field name) for property.</div> 228<dl> 229<dt><span class="simpleTagLabel">Since:</span></dt> 230<dd>2.1</dd> 231</dl> 232</li> 233</ul> 234</li> 235</ul> 236<ul class="blockList"> 237<li class="blockList"><a name="INDEX_UNKNOWN"> 238<!-- --> 239</a> 240<ul class="blockListLast"> 241<li class="blockList"> 242<h4>INDEX_UNKNOWN</h4> 243<pre>public static final int INDEX_UNKNOWN</pre> 244<div class="block">Marker value used to indicate that no index has been specified. 245 Used as the default value as annotations do not allow "missing" 246 values.</div> 247<dl> 248<dt><span class="simpleTagLabel">Since:</span></dt> 249<dd>2.4</dd> 250</dl> 251</li> 252</ul> 253</li> 254</ul> 255<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== --> 256<ul class="blockList"> 257<li class="blockList"><a name="annotation.type.element.detail"> 258<!-- --> 259</a> 260<h3>Element Detail</h3> 261<a name="value--"> 262<!-- --> 263</a> 264<ul class="blockList"> 265<li class="blockList"> 266<h4>value</h4> 267<pre>public abstract <a href="https://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> value</pre> 268<div class="block">Defines name of the logical property, i.e. JSON object field 269 name to use for the property. If value is empty String (which is the 270 default), will try to use name of the field that is annotated. 271 Note that there is 272 <b>no default name available for constructor arguments</b>, 273 meaning that 274 <b>Empty String is not a valid value for constructor arguments</b>.</div> 275<dl> 276<dt>Default:</dt> 277<dd>""</dd> 278</dl> 279</li> 280</ul> 281</li> 282</ul> 283<ul class="blockList"> 284<li class="blockList"><a name="required--"> 285<!-- --> 286</a> 287<ul class="blockList"> 288<li class="blockList"> 289<h4>required</h4> 290<pre>public abstract boolean required</pre> 291<div class="block">Property that indicates whether a value (which may be explicit 292 null) is expected for property during deserialization or not. 293 If expected, <code>BeanDeserialized</code> should indicate 294 this as a validity problem (usually by throwing an exception, 295 but this may be sent via problem handlers that can try to 296 rectify the problem, for example, by supplying a default 297 value). 298<p> 299 Note that as of 2.6, this property is only used for Creator 300 Properties, to ensure existence of property value in JSON: 301 for other properties (ones injected using a setter or mutable 302 field), no validation is performed. Support for those cases 303 may be added in future. 304 State of this property is exposed via introspection, and its 305 value is typically used by Schema generators, such as one for 306 JSON Schema.</div> 307<dl> 308<dt><span class="simpleTagLabel">Since:</span></dt> 309<dd>2.0</dd> 310</dl> 311<dl> 312<dt>Default:</dt> 313<dd>false</dd> 314</dl> 315</li> 316</ul> 317</li> 318</ul> 319<ul class="blockList"> 320<li class="blockList"><a name="index--"> 321<!-- --> 322</a> 323<ul class="blockList"> 324<li class="blockList"> 325<h4>index</h4> 326<pre>public abstract int index</pre> 327<div class="block">Property that indicates numerical index of this property (relative 328 to other properties specified for the Object). This index 329 is typically used by binary formats, but may also be useful 330 for schema languages and other tools.</div> 331<dl> 332<dt><span class="simpleTagLabel">Since:</span></dt> 333<dd>2.4</dd> 334</dl> 335<dl> 336<dt>Default:</dt> 337<dd>-1</dd> 338</dl> 339</li> 340</ul> 341</li> 342</ul> 343<ul class="blockList"> 344<li class="blockList"><a name="defaultValue--"> 345<!-- --> 346</a> 347<ul class="blockList"> 348<li class="blockList"> 349<h4>defaultValue</h4> 350<pre>public abstract <a href="https://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> defaultValue</pre> 351<div class="block">Property that may be used to <b>document</b> expected default value 352 for the property: most often used as source information for generating 353 schemas (like JSON Schema or protobuf/thrift schema), or documentation. 354 It may also be used by Jackson extension modules; core `jackson-databind` 355 does not have any automated handling beyond simply exposing this 356 value through bean property introspection. 357<p> 358 It is possible that in future this annotation could be used for value 359 defaulting, and especially for default values of Creator properties, 360 since they support <a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html#required--"><code>required()</code></a> in 2.6 and above.</div> 361<dl> 362<dt><span class="simpleTagLabel">Since:</span></dt> 363<dd>2.5</dd> 364</dl> 365<dl> 366<dt>Default:</dt> 367<dd>""</dd> 368</dl> 369</li> 370</ul> 371</li> 372</ul> 373<ul class="blockList"> 374<li class="blockList"><a name="access--"> 375<!-- --> 376</a> 377<ul class="blockListLast"> 378<li class="blockList"> 379<h4>access</h4> 380<pre>public abstract <a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.Access.html" title="enum in com.fasterxml.jackson.annotation">JsonProperty.Access</a> access</pre> 381<div class="block">Optional property that may be used to change the way visibility of 382 accessors (getter, field-as-getter) and mutators (constructor parameter, 383 setter, field-as-setter) is determined, either so that otherwise 384 non-visible accessors (like private getters) may be used; or that 385 otherwise visible accessors are ignored. 386<p> 387 Default value os <a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.Access.html#AUTO"><code>JsonProperty.Access.AUTO</code></a> which means that access is determined 388 solely based on visibility and other annotations.</div> 389<dl> 390<dt><span class="simpleTagLabel">Since:</span></dt> 391<dd>2.6</dd> 392</dl> 393<dl> 394<dt>Default:</dt> 395<dd>com.fasterxml.jackson.annotation.JsonProperty.Access.AUTO</dd> 396</dl> 397</li> 398</ul> 399</li> 400</ul> 401</li> 402</ul> 403</div> 404</div> 405<!-- ========= END OF CLASS DATA ========= --> 406<!-- ======= START OF BOTTOM NAVBAR ====== --> 407<div class="bottomNav"><a name="navbar.bottom"> 408<!-- --> 409</a> 410<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> 411<a name="navbar.bottom.firstrow"> 412<!-- --> 413</a> 414<ul class="navList" title="Navigation"> 415<li><a href="../../../../com/fasterxml/jackson/annotation/package-summary.html">Package</a></li> 416<li class="navBarCell1Rev">Class</li> 417<li><a href="class-use/JsonProperty.html">Use</a></li> 418<li><a href="package-tree.html">Tree</a></li> 419<li><a href="../../../../deprecated-list.html">Deprecated</a></li> 420<li><a href="../../../../index-all.html">Index</a></li> 421<li><a href="../../../../help-doc.html">Help</a></li> 422</ul> 423</div> 424<div class="subNav"> 425<ul class="navList"> 426<li><a href="../../../../com/fasterxml/jackson/annotation/JsonMerge.html" title="annotation in com.fasterxml.jackson.annotation"><span class="typeNameLink">Prev Class</span></a></li> 427<li><a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.Access.html" title="enum in com.fasterxml.jackson.annotation"><span class="typeNameLink">Next Class</span></a></li> 428</ul> 429<ul class="navList"> 430<li><a href="../../../../index.html?com/fasterxml/jackson/annotation/JsonProperty.html" target="_top">Frames</a></li> 431<li><a href="JsonProperty.html" target="_top">No Frames</a></li> 432</ul> 433<ul class="navList" id="allclasses_navbar_bottom"> 434<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> 435</ul> 436<div> 437<script type="text/javascript"><!-- 438 allClassesLink = document.getElementById("allclasses_navbar_bottom"); 439 if(window==top) { 440 allClassesLink.style.display = "block"; 441 } 442 else { 443 allClassesLink.style.display = "none"; 444 } 445 //--> 446</script> 447</div> 448<div> 449<ul class="subNavList"> 450<li>Summary: </li> 451<li><a href="#annotation.type.field.summary">Field</a> | </li> 452<li>Required | </li> 453<li><a href="#annotation.type.optional.element.summary">Optional</a></li> 454</ul> 455<ul class="subNavList"> 456<li>Detail: </li> 457<li><a href="#annotation.type.field.detail">Field</a> | </li> 458<li><a href="#annotation.type.element.detail">Element</a></li> 459</ul> 460</div> 461<a name="skip.navbar.bottom"> 462<!-- --> 463</a></div> 464<!-- ======== END OF BOTTOM NAVBAR ======= --> 465<p class="legalCopy"><small>Copyright © 2008–2019 <a href="http://fasterxml.com/">FasterXML</a>. All rights reserved.</small></p> 466</body> 467</html> 468