/*
 * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
 */
package wjb.baidu.ai.utils;

import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;

/**
 * Json工具类.
 */
public class GsonUtils {
	private static Gson gson = new GsonBuilder().create();

	public static String toJson(Object value) {
		return gson.toJson(value);
	}

	public static <T> T fromJson(String json, Class<T> classOfT) throws JsonParseException {
		return gson.fromJson(json, classOfT);
	}

	@SuppressWarnings("unchecked")
	public static <T> T fromJson(String json, Type typeOfT) throws JsonParseException {
		return (T) gson.fromJson(json, typeOfT);
	}
}
最近下载更多
coolcool123  LV1 3月17日
lironggang  LV38 2023年4月27日
97622282  LV1 2022年6月7日
王伟杰  LV2 2021年11月12日
淮竹  LV1 2021年10月13日
我是桃子呀  LV3 2021年7月14日
jokerYao  LV1 2020年11月27日
cas  LV9 2020年9月21日
sakura_fc  LV1 2020年9月10日
wanhaiq  LV3 2020年7月2日
最近浏览更多
coolcool123  LV1 3月17日
liyonggang  LV2 1月19日
miaoshi  LV16 1月3日
837055744 2023年7月20日
暂无贡献等级
2017143155  LV12 2023年6月27日
lironggang  LV38 2023年4月27日
nsq0006  LV6 2023年3月3日
lc4519  LV3 2023年3月3日
uni-code_0123  LV1 2023年1月10日
arkic1 2022年12月1日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友