🎨 Add null check for textJsonElement in WxCpUserGsonAdapter

This commit is contained in:
zhfkt 2025-07-04 15:40:29 +08:00 committed by GitHub
parent d52e225626
commit 84c69d4900
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -127,8 +127,12 @@ public class WxCpUserGsonAdapter implements JsonDeserializer<WxCpUser>, JsonSeri
switch (type) {
case 0: {
attr.setTextValue(GsonHelper.getString(attrJsonElement.getAsJsonObject().get("text").getAsJsonObject(),
"value"));
JsonElement textJsonElement = attrJsonElement.getAsJsonObject().get("text");
if (textJsonElement != null && !textJsonElement.isJsonNull() && textJsonElement.isJsonObject()) {
attr.setTextValue(GsonHelper.getString(textJsonElement.getAsJsonObject(), "value"));
} else {
attr.setTextValue(null); // Clear or set a default value to avoid stale data
}
break;
}
case 1: {