码迷,mamicode.com
首页 > Web开发 > 详细

实体类转json 和 json转实体类

时间:2020-07-16 18:16:37      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:key   实体类   har   parse   obj   ken   init   lan   line   

 

 

 

1.new JSONObject().toJSONString(rootEntity)
2. JSONObject jsonObject = JSONObject.fromObject(emp);
3.String s= JSONArray.fromObject(user).toString();

json对象中的list集合取出转为实体类集合:

List<User> userList = JSONArray.parseArray(dept.getUser(), User.class);

json转实体类

PriceListInitResult res = JSONObject.parseObject(itemStr, PriceListInitResult.class);

 

实体类转json 和 json转实体类

标签:key   实体类   har   parse   obj   ken   init   lan   line   

原文地址:https://www.cnblogs.com/xianz666/p/13322839.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!