-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Milestone
Description
I cannot get working @XmlElements
and @XmlAccessorType(XmlAccessType.NONE)
in Jackson 2.9.5. It ignores the field during serialization when I add XmlAccessorType annotation with NONE value.
@XmlElement
works fine.
public class NoneAccessTest extends BaseJaxbTest {
static class Foo {
private String foo;
public Foo() { }
public Foo(String foo) { this.foo = foo; }
public String getFoo() {
return foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
}
@XmlAccessorType(XmlAccessType.NONE)
static class NoneAccessBean
{
@XmlElements({
@XmlElement(type=Foo.class, name="foo")
})
public Object object;
@XmlElement
public Object other;
public NoneAccessBean() { }
public NoneAccessBean(Object o) { object = o; }
public NoneAccessBean(Object o, Object b) {
object = o;
other = b;
}
}
public void testNoneAccessWithXmlElements() throws Exception {
NoneAccessBean input = new NoneAccessBean(new Foo("foo"));
ObjectMapper mapper = getJaxbMapper();
String str = mapper.writeValueAsString(input);
assertEquals("{\"object\":{\"foo\":{\"foo\":\"foo\"}},\"other\":null}", str);
}
}
Result is:
Expected :{"object":{"foo":{"foo":"foo"}},"other":null}
Actual :{"other":null}
It used to work at least in 2.6 and seems to be a valid scenario.
Metadata
Metadata
Assignees
Labels
No labels