实体类转json 和 json转实体类


 

 

 

1.new JSONObject().toJSONString(rootEntity)
JSONObject.toJSONString(specPrices)//specPrices实体类
 
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);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM