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; } }
java将JSON字符串转换为实体类对象,基于net.sf.json实现
原文:http://blog.csdn.net/testcs_dn/article/details/42711339