用户信息添加新增的tagid_list属性

This commit is contained in:
BinaryWang
2016-09-28 13:19:36 +08:00
parent aabdc8e4b0
commit 742c74d850
9 changed files with 131 additions and 88 deletions

View File

@@ -9,6 +9,10 @@
package me.chanjar.weixin.common.util.json;
import java.util.List;
import com.google.common.collect.Lists;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -112,4 +116,21 @@ public class GsonHelper {
return r == null ? 0f : r;
}
public static Integer[] getIntArray(JsonObject o, String string) {
JsonArray jsonArray = getAsJsonArray(o.getAsJsonArray(string));
if (jsonArray == null) {
return null;
}
List<Integer> result = Lists.newArrayList();
for (int i = 0; i < jsonArray.size(); i++) {
result.add(jsonArray.get(i).getAsInt());
}
return result.toArray(new Integer[0]);
}
public static JsonArray getAsJsonArray(JsonElement element) {
return element == null ? null : element.getAsJsonArray();
}
}