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:
- Declaring them
transient
- Annotating them with @XStreamOmitField
- Calling xstream.omitField()
Or you can write your own converter.
精彩评论