Ghosterus
Ghosterus

Reputation: 105

JAXB: how to marshall HashMap<String, HashMap<String, String>>?

I have a complex structure of data, that can describe by HashMap inside HashMap. I need create XML file of structure. Like this:

<map>
    <key1>
        <map>
           <key1>someString1</key1>
           <key2>someString2</key2>
        </map>
    </key1>
    <key2>
        <map>
           <key1>someString1</key1>
           <key2>someString2</key2>
        </map>
    </key2>
</map>

But I noticed, JAXB has some problems with it. Is there any way to make XML from maps?

Upvotes: 0

Views: 348

Answers (1)

Harry Coder
Harry Coder

Reputation: 2740

You can not use JAXB to serialize directly a Map in to XML. You will have to use a Wrapper Class, that will serve you as the object tree. This link will help you.

Upvotes: 1

Related Questions