修改为fastjson

master
星期八 5 years ago
parent 26aabc7ccf
commit 6d54e61153
  1. 13
      proxy-common/src/main/java/org/fengfei/lanproxy/common/JsonUtil.java

@ -1,6 +1,6 @@
package org.fengfei.lanproxy.common; package org.fengfei.lanproxy.common;
import com.google.gson.Gson; import com.alibaba.fastjson.JSON;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
/** /**
@ -13,12 +13,8 @@ public class JsonUtil {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T json2object(String json, TypeToken<T> typeToken) { public static <T> T json2object(String json, TypeToken<T> typeToken) {
try {
Gson gson = new Gson(); return (T) JSON.parseObject(json,typeToken.getType());
return (T) gson.fromJson(json, typeToken.getType());
} catch (Exception e) {
}
return null;
} }
/** /**
@ -27,8 +23,7 @@ public class JsonUtil {
* *
*/ */
public static String object2json(Object obj) { public static String object2json(Object obj) {
Gson gson = new Gson(); return JSON.toJSONString(obj);
return gson.toJson(obj);
} }
} }
Loading…
Cancel
Save