Skip to content

Commit bd94102

Browse files
qsjiabinarywang
authored andcommitted
binarywang#674 修复微信返回0/1值转换为布尔值错误的问题
1 parent 4289bd5 commit bd94102

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassNewsArticleGsonAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.*;
44
import me.chanjar.weixin.common.util.json.GsonHelper;
55
import me.chanjar.weixin.mp.bean.WxMpMassNews;
6+
import org.apache.commons.lang3.BooleanUtils;
67

78
import java.lang.reflect.Type;
89

@@ -59,7 +60,7 @@ public WxMpMassNews.WxMpMassNewsArticle deserialize(JsonElement jsonElement, Typ
5960
}
6061
JsonElement showCoverPic = articleInfo.get("show_cover_pic");
6162
if (showCoverPic != null && !showCoverPic.isJsonNull()) {
62-
article.setShowCoverPic(GsonHelper.getAsBoolean(showCoverPic));
63+
article.setShowCoverPic(BooleanUtils.toBoolean(showCoverPic.getAsInt()));
6364
}
6465
return article;
6566
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsArticleGsonAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public WxMpMaterialNews.WxMpMaterialNewsArticle deserialize(JsonElement jsonElem
7878
}
7979
JsonElement showCoverPic = articleInfo.get("show_cover_pic");
8080
if (showCoverPic != null && !showCoverPic.isJsonNull()) {
81-
article.setShowCoverPic(GsonHelper.getAsBoolean(showCoverPic));
81+
article.setShowCoverPic(BooleanUtils.toBoolean(showCoverPic.getAsInt()));
8282
}
8383
JsonElement url = articleInfo.get("url");
8484
if (url != null && !url.isJsonNull()) {
@@ -87,12 +87,12 @@ public WxMpMaterialNews.WxMpMaterialNewsArticle deserialize(JsonElement jsonElem
8787

8888
JsonElement needOpenComment = articleInfo.get("need_open_comment");
8989
if (needOpenComment != null && !needOpenComment.isJsonNull()) {
90-
article.setNeedOpenComment(GsonHelper.getAsBoolean(needOpenComment));
90+
article.setNeedOpenComment(BooleanUtils.toBoolean(needOpenComment.getAsInt()));
9191
}
9292

9393
JsonElement onlyFansCanComment = articleInfo.get("only_fans_can_comment");
9494
if (onlyFansCanComment != null && !onlyFansCanComment.isJsonNull()) {
95-
article.setOnlyFansCanComment(GsonHelper.getAsBoolean(onlyFansCanComment));
95+
article.setOnlyFansCanComment(BooleanUtils.toBoolean(onlyFansCanComment.getAsInt()));
9696
}
9797
return article;
9898
}

0 commit comments

Comments
 (0)