json--json2bean
来源:互联网 发布:java中void意思 编辑:程序博客网 时间:2024/06/06 09:51
JSONObject jsonObject = null;
try{
jsonObject = JSONObject.fromObject(jsonStr);
}catch(Exception e){
loger.error("json字符串格式不对,转换json对象失败 {}"+e);
}
TestModel model = (TestModel)JSONObject.toBean(jsonObject, TestModel.class);
System.out.println(model.getName());
=======================================================================
//list2json
List<ZonePvByHour> hours = new ArrayList<ZonePvByHour>();
for(int i=0; i<2; i++){
ZonePvByHour hour = new ZonePvByHour();
hour.setDate("2013-09-09");
hour.setDate("2013-09-10");
hour.setPv(111);
hours.add(hour);
}
System.out.println(JSONArray.fromObject(hours).toString());
json2list
String jsonstr = [{"date":"2013-09-10","hour":"","id":0,"pv":111,"userId":0},{"date":"2013-09-10","hour":"","id":0,"pv":111,"userId":0}]
JSONArray aa = JSONArray.fromObject(jsonstr);
Collection c = JSONArray.toCollection(aa, ZonePvByHour.class);
Iterator i = c.iterator();
while(i.hasNext()){
ZonePvByHour zone = (ZonePvByHour)i.next();
System.out.println(zone.getDate());
System.out.println(zone.getPv());
}
- json--json2bean
- Json
- JSON
- JSON
- JSON
- json
- JSON
- JSON
- json
- Json
- json
- JSON
- json
- json
- JSON
- json
- JSON
- JSON
- 循环创建多线程时保证参数的有效性
- 区位码、gb2312、gbk编码之间的关系
- VC2010对Excel的操作
- poj2159
- Mysql中对表字段的增删改查
- json--json2bean
- python备份mysql数据库脚本一枚
- STL Port编译,Windows/Linux
- 编程语言认知
- ASIHTTP 终结者
- Windows 2012安装.NET Framework3.5(0x800F0907)
- 面试问题集锦二
- css box-shadow ie6-8
- 敏捷开发绩效管理之十一:如何提高人员可用率?