@@ -98,6 +98,10 @@ private void buildExtraAttrs(JsonObject o, WxCpUser user) {
9898 .setName (GsonHelper .getString (attrJsonElement .getAsJsonObject (), "name" ));
9999 user .getExtAttrs ().add (attr );
100100
101+ if (type == null ) {
102+ continue ;
103+ }
104+
101105 switch (type ) {
102106 case 0 : {
103107 attr .setTextValue (GsonHelper .getString (attrJsonElement .getAsJsonObject ().get ("text" ).getAsJsonObject (), "value" ));
@@ -120,6 +124,10 @@ private void buildExternalAttrs(JsonObject o, WxCpUser user) {
120124 final Integer type = GsonHelper .getInteger (element .getAsJsonObject (), "type" );
121125 final String name = GsonHelper .getString (element .getAsJsonObject (), "name" );
122126
127+ if (type == null ) {
128+ continue ;
129+ }
130+
123131 switch (type ) {
124132 case 0 : {
125133 user .getExternalAttrs ()
@@ -253,6 +261,12 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon
253261 for (WxCpUser .Attr attr : user .getExtAttrs ()) {
254262 JsonObject attrJson = new JsonObject ();
255263
264+ attrsJsonArray .add (attrJson );
265+
266+ if (attr .getType () == null ) {
267+ continue ;
268+ }
269+
256270 switch (attr .getType ()) {
257271 case 0 : {
258272 JsonObject text = new JsonObject ();
@@ -269,7 +283,6 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon
269283 }
270284 default : //ignored
271285 }
272- attrsJsonArray .add (attrJson );
273286 }
274287 JsonObject attrsJson = new JsonObject ();
275288 attrsJson .add ("attrs" , attrsJsonArray );
@@ -293,6 +306,13 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon
293306 JsonObject attrJson = new JsonObject ();
294307 attrJson .addProperty ("type" , attr .getType ());
295308 attrJson .addProperty ("name" , attr .getName ());
309+
310+ attrsJsonArray .add (attrJson );
311+
312+ if (attr .getType () == null ) {
313+ continue ;
314+ }
315+
296316 switch (attr .getType ()) {
297317 case 0 : {
298318 JsonObject text = new JsonObject ();
@@ -317,7 +337,6 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon
317337 }
318338 default ://忽略
319339 }
320- attrsJsonArray .add (attrJson );
321340 }
322341
323342 attrsJson .add (EXTERNAL_ATTR , attrsJsonArray );
0 commit comments