I have a class:
public class SomeClass {
public String a = "tag"
@JacksonXmlProperty(isAttribute = true)
public String b = "attribute"
}
I need to set variable b
as a property of variable a
:
<SomeClass>
<a b="attribute">tag</a>
</SomeClass>
I tried @JacksonXmlProperty(isAttribute = true)
, but it maps my attribute only to the root tag:
<SomeClass b="attribute">
<a>tag</a>
</SomeClass>
It there a way to handle this problem with annotations?
Create a new class A
public class A {
@JacksonXmlProperty(isAttribute = true)
public String b = "attribute"
}
And use it in your class:
public class SomeClass {
@JacksonXmlProperty
public A a = "tag"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.