利用gson将PageInfo<Bean>转为PageInfo<OutputBean>

        //pageInfo转outputPageInfo
        PageInfo<AdvertPageListOutputBean> outputPageInfo =
                new GsonBuilder().registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
                    public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
                        return new Date(json.getAsJsonPrimitive().getAsLong());
                    }
                }).create().fromJson(JSON.toJSONString(pageInfo), new TypeToken<PageInfo<AdvertPageListOutputBean>>() {}.getType());

猜你喜欢

转载自blog.csdn.net/xx897115293/article/details/107976037