From d3ebf5b103d4deebd6ffb75f4471a6fddab8d764 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 05 九月 2020 17:30:30 +0800 Subject: [PATCH] '微信登录' --- src/main/java/com/yeshi/buwan/iqiyi/IqiYiNewAPI.java | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/iqiyi/IqiYiNewAPI.java b/src/main/java/com/yeshi/buwan/iqiyi/IqiYiNewAPI.java index 5ceec05..5f4e64c 100644 --- a/src/main/java/com/yeshi/buwan/iqiyi/IqiYiNewAPI.java +++ b/src/main/java/com/yeshi/buwan/iqiyi/IqiYiNewAPI.java @@ -315,20 +315,21 @@ private static Gson gson = null; + static class DoubleTypeAdapter implements JsonDeserializer<Double> { + + @Override + public Double deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + if (json == null || json.getAsString().equalsIgnoreCase("")) { + return 0.0; + } else + return Double.parseDouble(json.getAsString()); + } + } + private static Gson getGson() { if (gson == null) gson = new GsonBuilder() - .registerTypeAdapter(double.class, new JsonDeserializer<Double>() { - - @Override - public Double deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - - if (json == null || json.getAsString().equalsIgnoreCase("")) { - return 0.0; - } else - return Double.parseDouble(json.getAsString()); - } - }) + .registerTypeAdapter(double.class, new DoubleTypeAdapter()) .registerTypeAdapter(int.class, new JsonDeserializer<Integer>() { @Override public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { @@ -350,7 +351,7 @@ if (data == null || data.equalsIgnoreCase("")) { return null; } else - return new Gson().fromJson(data, IqiyiAlbum2.StatisticsBean.class); + return new GsonBuilder().registerTypeAdapter(double.class, new DoubleTypeAdapter()).create().fromJson(data, IqiyiAlbum2.StatisticsBean.class); } }) .registerTypeAdapter(IqiyiAlbum2.VideoBean.class, new JsonDeserializer<IqiyiAlbum2.VideoBean>() { -- Gitblit v1.8.0