Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

企业微信更新员工自定义字段(网页类型)时,序列化失败 #1892

Closed
caowenhao opened this issue Nov 26, 2020 · 2 comments

Comments

@caowenhao
Copy link

caowenhao commented Nov 26, 2020

简要描述

更新员工自定义字段时,序列化失败

模块版本情况

  • WxJava 模块名: weixin-java-cp
  • WxJava 版本号: 3.9.0

详细描述

WxCpUserGsonAdapter中 JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationContext context)方法中网页类型没有设置type以及name的值

if (user.getExtAttrs().size() > 0) {
attrsJsonArray = new JsonArray();
Iterator var14 = user.getExtAttrs().iterator();
while(var14.hasNext()) {
Attr attr = (Attr)var14.next();
JsonObject attrJson = new JsonObject();
attrsJsonArray.add(attrJson);
if (attr.getType() == null) {
attrJson.addProperty("name", attr.getName());
attrJson.addProperty("value", attr.getTextValue());
} else {
switch(attr.getType()) {
case 0:
attrJson = new JsonObject();
attrJson.addProperty("value", attr.getTextValue());
attrJson.add("text", attrJson);
break;
case 1:
attrJson = new JsonObject();
attrJson.addProperty("url", attr.getWebUrl());
attrJson.addProperty("title", attr.getWebTitle());
attrJson.add("web", attrJson);
}
}
}

日志

转换后的json如下:
"extattr":{"attrs":[{"text":{"value":"01482"}},{"web":{"url":"https://www.baidu.com","title":"3-103"}}]},

@caowenhao caowenhao changed the title 更新员工自定义字段时,序列化失败 更新员工自定义字段(网页类型)时,序列化失败 Nov 26, 2020
@caowenhao caowenhao changed the title 更新员工自定义字段(网页类型)时,序列化失败 企业微信更新员工自定义字段(网页类型)时,序列化失败 Nov 26, 2020
@binarywang
Copy link
Member

你说的这个问题早已修复,建议你看真正的最新的源码,而不是反编译的代码。

@binarywang
Copy link
Member

参考 #1738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants