0

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?

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
coolsv
  • 268
  • 3
  • 17

1 Answers1

1

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"

}
Ori Marko
  • 56,308
  • 23
  • 131
  • 233