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

原文地址:https://www.cnblogs.com/LessNull/p/4478362.html