jackson-modules-java8
jackson-modules-java8 copied to clipboard
jackson-module-parameter-names: @JsonPropertyName still required if @JsonDeserialize is used
If ParameterNamesModule is registered, { "a": 1, "b": 1 } can be deserialized to an instance of:
public class Foo{
public Foo(int a, int b) { }
}
but not to an instance of:
public class Foo{
public Foo(@JsonDeserialize(converter=Incr.class) int a, int b) { }
}
unless you declare the property name again:
public class Foo{
public Foo(@JsonDeserialize(converter=Incr.class)@JsonProperty("a") int a, int b) { }
}
Interesting. Sounds like a flaw.
Can reproduce the issue; added a failing test.
Ah. I think I know the root cause: existence of a few "well-known" annotation triggers equivalent of returning empty String for name for (de)serialization -- meaning "use default". But I think creator detection logic does not realize this (as it is abstracted behind AnnotationIntrospector
)... and that needs to change, somehow. Fix needs to be in jackson-databind
, but issue can be here for now.
Created https://github.com/FasterXML/jackson-databind/issues/2932 -- unlikely to be resolved for 2.12, hope to address in 2.13.
Was fixed in jackson-databind
2.12.0, actually.