Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top