Skip to content

Commit 3ae057a

Browse files
committed
issue #95 获取关注者列表userList方法,当没有关注者时,报异常
1 parent 4740f1f commit 3ae057a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ public WxMpUserList deserialize(JsonElement json, Type typeOfT, JsonDeserializat
2222
wxMpUserList.setTotal(GsonHelper.getInteger(o, "total"));
2323
wxMpUserList.setCount(GsonHelper.getInteger(o, "count"));
2424
wxMpUserList.setNextOpenId(GsonHelper.getString(o, "next_openid"));
25-
JsonArray data = o.get("data").getAsJsonObject().get("openid").getAsJsonArray();
26-
for (int i = 0; i < data.size(); i++) {
27-
wxMpUserList.getOpenIds().add(GsonHelper.getAsString(data.get(i)));
25+
if (!o.get("data").isJsonNull() && !o.get("data").getAsJsonObject().get("openid").isJsonNull()) {
26+
JsonArray data = o.get("data").getAsJsonObject().get("openid").getAsJsonArray();
27+
for (int i = 0; i < data.size(); i++) {
28+
wxMpUserList.getOpenIds().add(GsonHelper.getAsString(data.get(i)));
29+
}
2830
}
2931
return wxMpUserList;
3032
}

0 commit comments

Comments
 (0)