【发布时间】:2011-11-09 15:03:48
【问题描述】:
我在 XStream 中遇到了别名问题。
我有一组字符串项,我想像这样序列化为 XML:
<types>
<type>abc</type>
<type>def</type>
</types>
但是,我似乎找不到解决此问题的好方法。我尝试了一个字符串列表,但最终得到了
<types>
<string>abc</string>
<string>def</string>
</types>
我也尝试将 String 放在一个简单的类中,但后来我得到了
<types>
<type>
<aType>abc</aType>
</type>
</types>
其中<type> 是自定义类的别名,aType 是类中的属性,即我使用这种方法获得了太多的级别。我将如何消除额外的级别或简单地将<string> 替换为自定义标签名称?
【问题讨论】:
标签: java collections xstream