I have a problem with Jackson to serialize nested object.
@Data
@AllArgsConstructor
@NoArgsConstructor
@JacksonXmlRootElement(localName = "A")
public class A {
@JacksonXmlProperty(isAttribute = true)
private String Iee;
@JacksonXmlProperty(localName = "B")
private B b;
}
@Data
@AllArgsConstructor
@JacksonXmlRootElement(localName = "B")
public class B {
@JacksonXmlProperty(isAttribute = true)
private String Jee;
}
When i serialize the Object A created like that :
final B b = new B("attribute B value");
final A a = new A("attribute A value", b);
final XmlMapper xmlMapper = new XmlMapper();
final String xml = xmlMapper.writeValueAsString(a);
I want this result :
<A Iee="attribute A value">
<B Jee="attribute B value" />
</A>
But i got this :
<A Iee="attribute A value">
<B Jee="attribute B value">
<Jee>attribute B value</Jee>
</B>
</A>
I search but i didn't found anything about that on google. Any idea ?
Best regards,