#674 修复微信返回0/1值转换为布尔值错误的问题

This commit is contained in:
QSJia
2018-07-12 10:34:48 +08:00
committed by Binary Wang
parent 4289bd5350
commit bd941025b6
2 changed files with 5 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.util.json;
import com.google.gson.*;
import me.chanjar.weixin.common.util.json.GsonHelper;
import me.chanjar.weixin.mp.bean.WxMpMassNews;
import org.apache.commons.lang3.BooleanUtils;
import java.lang.reflect.Type;
@@ -59,7 +60,7 @@ public class WxMpMassNewsArticleGsonAdapter implements JsonSerializer<WxMpMassNe
}
JsonElement showCoverPic = articleInfo.get("show_cover_pic");
if (showCoverPic != null && !showCoverPic.isJsonNull()) {
article.setShowCoverPic(GsonHelper.getAsBoolean(showCoverPic));
article.setShowCoverPic(BooleanUtils.toBoolean(showCoverPic.getAsInt()));
}
return article;
}

View File

@@ -78,7 +78,7 @@ public class WxMpMaterialNewsArticleGsonAdapter implements JsonSerializer<WxMpMa
}
JsonElement showCoverPic = articleInfo.get("show_cover_pic");
if (showCoverPic != null && !showCoverPic.isJsonNull()) {
article.setShowCoverPic(GsonHelper.getAsBoolean(showCoverPic));
article.setShowCoverPic(BooleanUtils.toBoolean(showCoverPic.getAsInt()));
}
JsonElement url = articleInfo.get("url");
if (url != null && !url.isJsonNull()) {
@@ -87,12 +87,12 @@ public class WxMpMaterialNewsArticleGsonAdapter implements JsonSerializer<WxMpMa
JsonElement needOpenComment = articleInfo.get("need_open_comment");
if (needOpenComment != null && !needOpenComment.isJsonNull()) {
article.setNeedOpenComment(GsonHelper.getAsBoolean(needOpenComment));
article.setNeedOpenComment(BooleanUtils.toBoolean(needOpenComment.getAsInt()));
}
JsonElement onlyFansCanComment = articleInfo.get("only_fans_can_comment");
if (onlyFansCanComment != null && !onlyFansCanComment.isJsonNull()) {
article.setOnlyFansCanComment(GsonHelper.getAsBoolean(onlyFansCanComment));
article.setOnlyFansCanComment(BooleanUtils.toBoolean(onlyFansCanComment.getAsInt()));
}
return article;
}