You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of continuing work to more seamlessly support addition of argument name information (by JDK8, paranamer, or other mechanism), it makes sense to allow auto-detect of creators even without @JsonCreator annotation if:
All parameters have name (implicit or explicit), or are marked as injectable AND
There are no other visible constructors AND
There is no default (no-arg) constructor (which otherwise would be detected regardless of visibility)
In addition, there is one practical limitation due to existing resolution rules:
Single-argument constructor will default to "delegating" constructor, so implicit names are only used if @JsonCreator is used to indicate "property-based" constructor use, or explicit names.
Note, too, that language modules (like jackson-module-scala) may refine rules for more accurate detection of the "main" constructor; this functionality refers to vanilla handling for Java.
The text was updated successfully, but these errors were encountered:
cowtowncoder
changed the title
Auto-detect multi-argument constructor with implicit names if the only visible creator
Auto-detect multi-argument constructor with implicit names if it is the only visible creator
Mar 16, 2015
Can not construct instance of ...$Person: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: {"name":"John","age":20}; line: 1, column: 2]
com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of ...$Person: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: {"name":"John","age":20}; line: 1, column: 2]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)
at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:1456)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1012)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1205)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:314)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:148)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842)
As part of continuing work to more seamlessly support addition of argument name information (by JDK8, paranamer, or other mechanism), it makes sense to allow auto-detect of creators even without
@JsonCreator
annotation if:In addition, there is one practical limitation due to existing resolution rules:
@JsonCreator
is used to indicate "property-based" constructor use, or explicit names.Note, too, that language modules (like
jackson-module-scala
) may refine rules for more accurate detection of the "main" constructor; this functionality refers to vanilla handling for Java.The text was updated successfully, but these errors were encountered: