1. 程式人生 > >java將JSON字串轉換為實體類物件,基於net sf json實現

java將JSON字串轉換為實體類物件,基於net sf json實現

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow

也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!

               

java將JSON字串轉換為實體類物件

        @SuppressWarnings("unchecked"public
static <T> T jsonToObject(String jsonString, Class<T> pojoCalss) {  try{   Object pojo;   net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(jsonString);   pojo = net.sf.json.JSONObject.toBean(jsonObject, pojoCalss);   return
(T)pojo;  }catch(Exception ex){   ex.printStackTrace();      return null;  } }


           

給我老師的人工智慧教程打call!http://blog.csdn.net/jiangjunshow

這裡寫圖片描述