Howto prevent XStream from displaying class=“string”?

江枫思渺然 提交于 2020-01-17 01:18:10

问题


Is there a way to prevent XStream from displaying something like follows:

<user class="string">user</user>
<password class="string">password</password>

in an xml output?


回答1:


Omitted Fields

For a proper deserialization XStream has to write the complete object graph into XML that is referenced by a single object. Therefore XStream has to find a representation that contains all aspects to recreate the objects.

However, some parts might be superfluous e.g. if a member field is lazy initialized and its content can be easily recreated. In such a case a field can be omitted using XStream.omitField(Class, String).

@See: xStream Documentation



来源:https://stackoverflow.com/questions/5541677/howto-prevent-xstream-from-displaying-class-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!