[b][color=red]开发者博客:[url]http://www.developsearch.com[/url][/color][/b]
/**
* JSON解析工具类
*
* @author chenxin
* @version [版本号, 2012-5-21]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class GsonUtil {
/**
* 把json串转为指定的对象
*
* @param <T>
*/
public static <T> T fromJson(String str, Class<T> clazz)
{
return (T)JSON.parseObject(str, clazz);
}
/**
* 把对象转为json串
*/
public static String toJson(Object obj)
{
return JSON.toJSONString(obj, mapping);
}
}