输出结果:
<Person-array>
  <Person>
    <name>Jay</name>
    <age>24</age>
  </Person>
  <Person>
    <name>Tom</name>
    <age>23</age>
  </Person>
</Person-array>
  3、JSON格式

//参考:http://www.cnblogs.com/hoojo/archive/2011/04/22/2025197.html
public class SerializeJSON {

 public static void main(String[] args) {
  SerializeJSON serializeJSON = new SerializeJSON();
  serializeJSON.writeJSON();
  serializeJSON.readJSON();
 }

 public void writeJSON(){
  XStream xStream = new XStream(new JettisonMappedXmlDriver());
  Person person = new Person("geniushehe", 16);
  try {
   FileOutputStream fos = new FileOutputStream("E:\json.js");
   xStream.setMode(XStream.NO_REFERENCES);
   xStream.alias("Person", Person.class);
   xStream.toXML(person, fos);
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  }
 }
 public void readJSON(){
  XStream xStream = new XStream(new JettisonMappedXmlDriver());
  Person person = null;
  try {
   FileInputStream fis = new FileInputStream("E:\json.js");
   xStream.setMode(XStream.NO_REFERENCES);
   xStream.alias("Person", Person.class);
   person = (Person)xStream.fromXML(fis);
   System.out.println(person.getName());
   System.out.println(person.getAge());
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  }
 }
}
   输出结果:

{"Person":{"name":"geniushehe","age":16}}