开发者

XStream serializing collections

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜