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
This is similar to a previous issue (#541), but I think is a bit different because the previous issue didn't use mix-ins, which might the cause of the trouble I'm getting.
public class TestData {
public interface View {}
public interface MixIn {
@JsonProperty("decoratedProp")
Long getProp();
}
// does not work on the field:
// @JsonView(View.class)
private final Long prop;
// does work on the getter:
@JsonView(View.class)
public Long getProp() { return prop; }
@JsonCreator
public TestData(@JsonProperty("prop") Long prop) {
this.prop = prop;
}
}
I serialise in using an object mapper without the MixIn, using the JSON: {"prop":123}.
I serialise out using an object mapper where the MixIn has been added, using the TestData.View view. I expect to get the JSON {"decoratedProp":123}, but instead I get {"prop":123}, plus the following exception in my logs:
T+546256 [http-nio-8443-exec-6] WARN o.s.h.c.j.MappingJackson2HttpMessageConverter - Failed to evaluate serialization for type [class c.r.s.a.a.d.TestData]: java.lang.IllegalStateException: Conflicting/ambiguous property name definitions (implicit name 'prop'): found multiple explicit names: [prop, decoratedProp], but also implicit accessor: [field c.r.s.a.a.d.TestData#prop][visible=true,ignore=false,explicitName=false]
Note that the problem goes away if I switch to setting the @JsonView() annotation on the getter method, rather than the field. Also, the problem goes away if I remove the @JsonProperty() from the constructor and instead create the objects directly and then serialise them out.
The text was updated successfully, but these errors were encountered:
This is similar to a previous issue (#541), but I think is a bit different because the previous issue didn't use mix-ins, which might the cause of the trouble I'm getting.
I serialise in using an object mapper without the MixIn, using the JSON:
{"prop":123}
.I serialise out using an object mapper where the MixIn has been added, using the
TestData.View
view. I expect to get the JSON{"decoratedProp":123}
, but instead I get{"prop":123}
, plus the following exception in my logs:T+546256 [http-nio-8443-exec-6] WARN o.s.h.c.j.MappingJackson2HttpMessageConverter - Failed to evaluate serialization for type [class c.r.s.a.a.d.TestData]: java.lang.IllegalStateException: Conflicting/ambiguous property name definitions (implicit name 'prop'): found multiple explicit names: [prop, decoratedProp], but also implicit accessor: [field c.r.s.a.a.d.TestData#prop][visible=true,ignore=false,explicitName=false]
Note that the problem goes away if I switch to setting the
@JsonView()
annotation on the getter method, rather than the field. Also, the problem goes away if I remove the@JsonProperty()
from the constructor and instead create the objects directly and then serialise them out.The text was updated successfully, but these errors were encountered: