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 Thu Jul 07 10:49:27 PDT 2016 --> 6<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7<title>JsonCreator (Jackson-annotations 2.8.0 API)</title> 8<meta name="date" content="2016-07-07"> 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="JsonCreator (Jackson-annotations 2.8.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/JsonCreator.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/JsonClassDescription.html" title="annotation in com.fasterxml.jackson.annotation"><span class="strong">Prev Class</span></a></li> 40<li><a href="../../../../com/fasterxml/jackson/annotation/JsonCreator.Mode.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/JsonCreator.html" target="_top">Frames</a></li> 44<li><a href="JsonCreator.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 JsonCreator" class="title">Annotation Type JsonCreator</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#CONSTRUCTOR" title="class or interface in java.lang.annotation">CONSTRUCTOR</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">JsonCreator</span></pre> 90<div class="block">Marker annotation that can be used to define constructors and factory 91 methods as one to use for instantiating new instances of the associated 92 class. 93<p> 94 NOTE: when annotating creator methods (constructors, factory methods), 95 method must either be: 96<ul> 97 <li>Single-argument constructor/factory method without <a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html" title="annotation in com.fasterxml.jackson.annotation"><code>JsonProperty</code></a> 98 annotation for the argument: if so, this is so-called "delegate creator", 99 in which case Jackson first binds JSON into type of the argument, and 100 then calls creator. This is often used in conjunction with <a href="../../../../com/fasterxml/jackson/annotation/JsonValue.html" title="annotation in com.fasterxml.jackson.annotation"><code>JsonValue</code></a> 101 (used for serialization). 102 </li> 103 <li>Constructor/factory method where <b>every argument</b> is annotated with 104 either <a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html" title="annotation in com.fasterxml.jackson.annotation"><code>JsonProperty</code></a> or <a href="../../../../com/fasterxml/jackson/annotation/JacksonInject.html" title="annotation in com.fasterxml.jackson.annotation"><code>JacksonInject</code></a>, to indicate name 105 of property to bind to 106 </li> 107 </ul> 108 Also note that all <a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html" title="annotation in com.fasterxml.jackson.annotation"><code>JsonProperty</code></a> annotations must specify actual name 109 (NOT empty String for "default") unless you use one of extension modules 110 that can detect parameter name; this because default JDK versions before 8 111 have not been able to store and/or retrieve parameter names from bytecode. 112 But with JDK 8 (or using helper libraries such as Paranamer, or other JVM 113 languages like Scala or Kotlin), specifying name is optional. 114<p> 115 One common use case is to use a delegating Creator to construct instances from 116 scalar values (like <code>java.lang.String</code>) during deserialization, 117 and serialize values using <a href="../../../../com/fasterxml/jackson/annotation/JsonValue.html" title="annotation in com.fasterxml.jackson.annotation"><code>JsonValue</code></a>. 118<p> 119 NOTE: As of Jackson 2.6, use of <a href="../../../../com/fasterxml/jackson/annotation/JsonProperty.html#required()"><code>JsonProperty.required()</code></a> is supported 120 for Creator methods (but not necessarily for regular setters or fields!).</div> 121<dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../com/fasterxml/jackson/annotation/JsonCreator.html" title="annotation in com.fasterxml.jackson.annotation"><code>JsonCreator</code></a></dd></dl> 122</li> 123</ul> 124</div> 125<div class="summary"> 126<ul class="blockList"> 127<li class="blockList"> 128<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== --> 129<ul class="blockList"> 130<li class="blockList"><a name="annotation_type_optional_element_summary"> 131<!-- --> 132</a> 133<h3>Optional Element Summary</h3> 134<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation"> 135<caption><span>Optional Elements</span><span class="tabEnd"> </span></caption> 136<tr> 137<th class="colFirst" scope="col">Modifier and Type</th> 138<th class="colLast" scope="col">Optional Element and Description</th> 139</tr> 140<tr class="altColor"> 141<td class="colFirst"><code><a href="../../../../com/fasterxml/jackson/annotation/JsonCreator.Mode.html" title="enum in com.fasterxml.jackson.annotation">JsonCreator.Mode</a></code></td> 142<td class="colLast"><code><strong><a href="../../../../com/fasterxml/jackson/annotation/JsonCreator.html#mode()">mode</a></strong></code> 143<div class="block">Property that is used to indicate how argument(s) is/are bound for creator, 144 in cases there may be multiple alternatives.</div> 145</td> 146</tr> 147</table> 148</li> 149</ul> 150</li> 151</ul> 152</div> 153<div class="details"> 154<ul class="blockList"> 155<li class="blockList"> 156<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== --> 157<ul class="blockList"> 158<li class="blockList"><a name="annotation_type_element_detail"> 159<!-- --> 160</a> 161<h3>Element Detail</h3> 162<a name="mode()"> 163<!-- --> 164</a> 165<ul class="blockListLast"> 166<li class="blockList"> 167<h4>mode</h4> 168<pre>public abstract <a href="../../../../com/fasterxml/jackson/annotation/JsonCreator.Mode.html" title="enum in com.fasterxml.jackson.annotation">JsonCreator.Mode</a> mode</pre> 169<div class="block">Property that is used to indicate how argument(s) is/are bound for creator, 170 in cases there may be multiple alternatives. Currently the one case is that 171 of a single-argument creator method, for which both so-called "delegating" and 172 "property-based" bindings are possible: since 173 delegating mode can not be used for multi-argument creators, the only choice 174 there is "property-based" mode. 175 Check <a href="../../../../com/fasterxml/jackson/annotation/JsonCreator.Mode.html" title="enum in com.fasterxml.jackson.annotation"><code>JsonCreator.Mode</code></a> for more complete explanation of possible choices. 176<p> 177 Default value of <a href="../../../../com/fasterxml/jackson/annotation/JsonCreator.Mode.html#DEFAULT"><code>JsonCreator.Mode.DEFAULT</code></a> means that caller is to use standard 178 heuristics for choosing mode to use.</div> 179<dl><dt><span class="strong">Since:</span></dt> 180 <dd>2.5</dd></dl> 181<dl> 182<dt>Default:</dt> 183<dd>com.fasterxml.jackson.annotation.JsonCreator.Mode.DEFAULT</dd> 184</dl> 185</li> 186</ul> 187</li> 188</ul> 189</li> 190</ul> 191</div> 192</div> 193<!-- ========= END OF CLASS DATA ========= --> 194<!-- ======= START OF BOTTOM NAVBAR ====== --> 195<div class="bottomNav"><a name="navbar_bottom"> 196<!-- --> 197</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> 198<!-- --> 199</a> 200<ul class="navList" title="Navigation"> 201<li><a href="../../../../com/fasterxml/jackson/annotation/package-summary.html">Package</a></li> 202<li class="navBarCell1Rev">Class</li> 203<li><a href="class-use/JsonCreator.html">Use</a></li> 204<li><a href="package-tree.html">Tree</a></li> 205<li><a href="../../../../deprecated-list.html">Deprecated</a></li> 206<li><a href="../../../../index-all.html">Index</a></li> 207<li><a href="../../../../help-doc.html">Help</a></li> 208</ul> 209</div> 210<div class="subNav"> 211<ul class="navList"> 212<li><a href="../../../../com/fasterxml/jackson/annotation/JsonClassDescription.html" title="annotation in com.fasterxml.jackson.annotation"><span class="strong">Prev Class</span></a></li> 213<li><a href="../../../../com/fasterxml/jackson/annotation/JsonCreator.Mode.html" title="enum in com.fasterxml.jackson.annotation"><span class="strong">Next Class</span></a></li> 214</ul> 215<ul class="navList"> 216<li><a href="../../../../index.html?com/fasterxml/jackson/annotation/JsonCreator.html" target="_top">Frames</a></li> 217<li><a href="JsonCreator.html" target="_top">No Frames</a></li> 218</ul> 219<ul class="navList" id="allclasses_navbar_bottom"> 220<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> 221</ul> 222<div> 223<script type="text/javascript"><!-- 224 allClassesLink = document.getElementById("allclasses_navbar_bottom"); 225 if(window==top) { 226 allClassesLink.style.display = "block"; 227 } 228 else { 229 allClassesLink.style.display = "none"; 230 } 231 //--> 232</script> 233</div> 234<div> 235<ul class="subNavList"> 236<li>Summary: </li> 237<li>Required | </li> 238<li><a href="#annotation_type_optional_element_summary">Optional</a></li> 239</ul> 240<ul class="subNavList"> 241<li>Detail: </li> 242<li><a href="#annotation_type_element_detail">Element</a></li> 243</ul> 244</div> 245<a name="skip-navbar_bottom"> 246<!-- --> 247</a></div> 248<!-- ======== END OF BOTTOM NAVBAR ======= --> 249<p class="legalCopy"><small>Copyright © 2008–2016 <a href="http://fasterxml.com/">FasterXML</a>. All rights reserved.</small></p> 250</body> 251</html> 252