java將JSON字符串轉換為實體類對象,基於net.sf.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;
        }
    }

http://blog.csdn.net/testcs_dn/article/details/42711339


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM