简体   繁体   English

JAXB:如何编组 HashMap <String, HashMap<String, String> &gt;?

[英]JAXB: how to marshall HashMap<String, HashMap<String, String>>?

I have a complex structure of data, that can describe by HashMap inside HashMap.我有一个复杂的数据结构,可以通过 HashMap 内部的 HashMap 来描述。 I need create XML file of structure.我需要创建结构的 XML 文件。 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.但我注意到,JAXB 有一些问题。 Is there any way to make XML from maps?有没有办法从地图制作 XML?

You can not use JAXB to serialize directly a Map in to XML .您不能使用 JAXB 将Map直接序列化为XML You will have to use a Wrapper Class , that will serve you as the object tree.您将不得不使用Wrapper Class ,它将作为对象树为您服务。 This link will help you.链接将帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM