开发者

XStream serializing collections

开发者 https://www.devze.com 2022-12-11 04:10 出处:网络
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

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

精彩评论

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