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