Jaseto
a <Java Serialization Toolkit>



As an example, consider the following class declaration (for the sake of conciseness, getters/setter for the private attributes are not listed):

public class Person
{
  private Set friends = new HashSet();
  private String name;
  private int age;
}
			
Let's make an instance of this class.
Person luc = new Person();
luc.setName("Luc Hogie");
luc.setAge(37);
			
Serializing

And get the XML representation of this instance:

String xml = Jaseto.toXML(luc);
			
This will produce this XML description:
<object age="37" class="Person" name="Luc">
  <friends>
    <collection class="java.util.HashSet" />
  </friends>
</object>
			

Deserializing

In the other way around, to obtain an object out of its XML description, the following call suffices:

Person anotherLuc = Jaseto.fromXML(xml);
			

Excluding a field

Doing this:

Jaseto.getFieldsName(Person.class).remove("friends");
			
This remove the friends field from the resulting XML text.
<object age="37" class="Person" name="Luc" />