XStream serializing collections

烂漫一生 提交于 2019-12-11 04:16:50

问题


I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that are stored in the collection (primarily their IDs, and not the remaining contents of each element).

Anyone have an idea of how I might go about this?

Thanks


回答1:


You can specify that all the collection element fields except for ID should not be serialized by either:

  1. Declaring them transient
  2. Annotating them with @XStreamOmitField
  3. Calling xstream.omitField()

Or you can write your own converter.



来源:https://stackoverflow.com/questions/1730314/xstream-serializing-collections

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