🎨 #3752 修复 Gson 在 Java 9+ 环境下反射访问 java.io.File#path 字段失败的问题
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package me.chanjar.weixin.cp.util.json;
|
||||
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import me.chanjar.weixin.common.bean.menu.WxMenu;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
|
||||
import me.chanjar.weixin.common.util.json.WxErrorAdapter;
|
||||
import me.chanjar.weixin.cp.bean.WxCpChat;
|
||||
import me.chanjar.weixin.cp.bean.WxCpDepart;
|
||||
@@ -11,6 +14,7 @@ import me.chanjar.weixin.cp.bean.WxCpTag;
|
||||
import me.chanjar.weixin.cp.bean.WxCpUser;
|
||||
import me.chanjar.weixin.cp.bean.kf.WxCpKfGetCorpStatisticResp;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -32,6 +36,18 @@ public class WxCpGsonBuilder {
|
||||
INSTANCE.registerTypeAdapter(WxMenu.class, new WxCpMenuGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxCpTag.class, new WxCpTagGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxCpKfGetCorpStatisticResp.StatisticList.class, new StatisticListAdapter());
|
||||
|
||||
INSTANCE.setExclusionStrategies(new ExclusionStrategy() {
|
||||
@Override
|
||||
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSkipClass(Class<?> aClass) {
|
||||
return aClass == File.class || aClass == ApacheHttpClientBuilder.class;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user