package ru.golodnyj.lection.json; import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver; import com.thoughtworks.xstream.XStream; /** * Date: 26.08.2009 * Time: 7:25:40 * * @author golodnyj * @version 0.1 */ public class ConsoleJSON { public static void main(String[] args) { Client c = new Client("name",true , 5); // Создание XML XStream xstream = new XStream(new DomDriver()); //xstream.alias("client", Client.class); String xml = xstream.toXML(c); System.out.println("xml "+ xml.length() +" : \n" + xml); // Создание JSON XStream xstream1 = new XStream(new JsonHierarchicalStreamDriver()); //XStream xstream1 = new XStream(new JettisonMappedXmlDriver()); //xstream1.alias("client", Client.class); String json = xstream1.toXML(c); System.out.println("json "+ json.length() +" : \n" + json); } }