| @@ -10,29 +10,29 @@ package me.chanjar.weixin.mp.util.json; | |||||
| import com.google.gson.*; | import com.google.gson.*; | ||||
| import me.chanjar.weixin.common.util.json.GsonHelper; | import me.chanjar.weixin.common.util.json.GsonHelper; | ||||
| import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult; | |||||
| import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem; | |||||
| import java.lang.reflect.Type; | import java.lang.reflect.Type; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| public class WxMpMaterialFileBatchGetGsonItemAdapter implements JsonDeserializer<WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem> { | |||||
| public class WxMpMaterialFileBatchGetGsonItemAdapter implements JsonDeserializer<WxMaterialFileBatchGetNewsItem> { | |||||
| @Override | @Override | ||||
| public WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { | |||||
| WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem wxMaterialFileBatchGetNewsItem = new WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem(); | |||||
| public WxMaterialFileBatchGetNewsItem deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { | |||||
| WxMaterialFileBatchGetNewsItem newsItem = new WxMaterialFileBatchGetNewsItem(); | |||||
| JsonObject json = jsonElement.getAsJsonObject(); | JsonObject json = jsonElement.getAsJsonObject(); | ||||
| if (json.get("media_id") != null && !json.get("media_id").isJsonNull()) { | if (json.get("media_id") != null && !json.get("media_id").isJsonNull()) { | ||||
| wxMaterialFileBatchGetNewsItem.setMediaId(GsonHelper.getAsString(json.get("media_id"))); | |||||
| newsItem.setMediaId(GsonHelper.getAsString(json.get("media_id"))); | |||||
| } | } | ||||
| if (json.get("update_time") != null && !json.get("update_time").isJsonNull()) { | if (json.get("update_time") != null && !json.get("update_time").isJsonNull()) { | ||||
| wxMaterialFileBatchGetNewsItem.setUpdateTime(new Date(1000 * GsonHelper.getAsLong(json.get("update_time")))); | |||||
| newsItem.setUpdateTime(new Date(1000 * GsonHelper.getAsLong(json.get("update_time")))); | |||||
| } | } | ||||
| if (json.get("name") != null && !json.get("name").isJsonNull()) { | if (json.get("name") != null && !json.get("name").isJsonNull()) { | ||||
| wxMaterialFileBatchGetNewsItem.setName(GsonHelper.getAsString(json.get("name"))); | |||||
| newsItem.setName(GsonHelper.getAsString(json.get("name"))); | |||||
| } | } | ||||
| if (json.get("url") != null && !json.get("url").isJsonNull()) { | if (json.get("url") != null && !json.get("url").isJsonNull()) { | ||||
| wxMaterialFileBatchGetNewsItem.setUrl(GsonHelper.getAsString(json.get("url"))); | |||||
| newsItem.setUrl(GsonHelper.getAsString(json.get("url"))); | |||||
| } | } | ||||
| return wxMaterialFileBatchGetNewsItem; | |||||
| return newsItem; | |||||
| } | } | ||||
| } | } | ||||