實體類轉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