fireBand fireBand - 1 year ago 112
Java Question

XStream- not include some values

I want to include objects from 3 different classes in one xml.

I am planning to created another class to hold a list of these objects.

I need only subset of values from these objects.

Is there a way to omit few values while generating xml from XStream?


Answer Source

Try using the @XStreamOmitField annotation.

Take a look at the documentation here:

The below is from the documentation:

class RendezvousMessage {

  private int messageType;

  private List<String> content;

  @XStreamConverter(value=BooleanConverter.class, booleans={false}, strings={"yes", "no"})
  private boolean important;

  private Calendar created = new GregorianCalendar();

  public RendezvousMessage(int messageType, boolean important, String... content) {
    this.messageType = messageType;
    this.important = important;
    this.content = Arrays.asList(content);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download