java将JSON字符串转换为实体类对象,基于net.sf.json实现

前端之家收集整理的这篇文章主要介绍了java将JSON字符串转换为实体类对象,基于net.sf.json实现前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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; } }


猜你在找的PHP相关文章