xstream ——---json
来源:互联网 发布:网络插座接线图 编辑:程序博客网 时间:2024/06/06 08:52
XStream支持JSON通过初始化XStream对象适当的驱动程序。 XStream目前支持JettisonMappedXmlDriver和JsonHierarchicalStreamDriver。
package com.xstream.demo1;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
import com.thoughtworks.xstream.io.json.JsonWriter;
import com.xstream.vo1.Address;
import com.xstream.vo1.Addresses;
public class XstreamJsonDemo {
public static void main(String args[]){
XstreamJsonDemo tester = new XstreamJsonDemo();
XStream xstream = new XStream(new JsonHierarchicalStreamDriver() {
public HierarchicalStreamWriter createWriter(Writer writer) {
return new JsonWriter(writer, JsonWriter.DROP_ROOT_MODE);
}
});
List<Address> list = new ArrayList<Address>();
Address address1 = new Address("t1", "p1");
Address address2 = new Address("t2", "p2");
list.add(address1);
list.add(address2);
Addresses addresses = new Addresses(list);
xstream.setMode(XStream.NO_REFERENCES);
xstream.alias("addresses", Addresses.class);
System.out.println(xstream.toXML(addresses));
}
}
- xstream ——---json
- Ajax——XStream
- xStream转换XML、JSON
- ajaxday2 ajax json xstream
- xStream转换XML、JSON
- AJAX、XStream、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- xStream完美转换XML、JSON
- @Autowired 知识点
- 百度编辑器UEditor常用设置函数大全和注意事项
- Android UI性能优化实战 识别绘制中的性能问题
- 数据结构图
- 索引
- xstream ——---json
- c#内存管理
- ubunbu下编译android源码
- Go-strings
- 比如notification.flags |= Notification.FLAG_AUTO_CANCEL “|=”是啥意思?
- R语言从基础入门到提高(六) frame 框架
- dubbo本地模拟RPC
- AWS 的使用
- ASP.NET的字符编码问题