views:

21

answers:

2

How to skip certain fields of object in serialization of Obj to XML.

code is here

A: 

mark the fields to skip with the 'transient' keyword

Example based on your code:

public class Foo {
public transient int a;
public String b;
public Bar boo;
public Foo(int a, String b, Bar c) {
    this.a = a;
    this.b = b;
    this.boo = c;
}

}

the property a will not be serialized to XML

Jeroen Rosenberg
Thanks Jeroen...
NewBeee_Java
+1  A: 

From Xtream

How do I specify that a field should not be serialized?

Make it transient, specify it with XStream.omitField() or annotate it with @XStreamOmitField

Try www.google.com

GHad