1

i have little bit trouble with deserialization of XML. I am only able to deserialize this xml by:

@JacksonXmlProperty(localName = "field")
@JacksonXmlElementWrapper(useWrapping = false)
List<Object> field;

This is my xml:

   <Response>
       <user>
          <field attribute="x"></field>
          <field attribute="y">false</field>
          <field attribute="z">string</field>
       </user>
       <user>
          <field attribute="x"></field>
          <field attribute="y">false</field>
          <field attribute="z">string</field>
       </user>
   </Response>

Problem is, that i want to replace Object in List<Object> field; with some specific class so i could access attribute and the value in field.

With Object, i am able to create something like this:

user='[{attribute=x}, {attribute=y, =false}, {name=z, =string}]

thanks a lot.

1 Answer 1

2

Found answer. I created new class that contains this elements:

        @JacksonXmlProperty(isAttribute = true, localName = "attribute")
        String attribute;

        @JacksonXmlText
        String value;

And replace the Object with this new class.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.