json字符串和java对象的互相转换

来源:互联网 发布:淘宝店铺不装修可以吗 编辑:程序博客网 时间:2024/05/17 10:57
//把java对象存为json对象数组JSONArray json = JSONArray.fromObject(list);//把java对象存为json对象JSONObject json1= JSONObject.fromObject(list);//json字符串转为json数组JSONArray json = JSONArray.fromObject(personstr);List<InvoidPerson> persons = (List<InvoidPerson>)JSONArray.toCollection(json, nvoidPerson.class);//json字符串转为json对象JSONObject jsonobject = JSONObject.fromObject(str);passportlends = (PassportLendsEntity)JSONObject.toBean(jsonobject, PassportLendsEntity.class);

 

0 0