Bootstrap

com.google.gson.internal.LinkedTreeMap cannot be cast to xxx

问题描述

Gson泛型解析时Json报错:com.google.gson.internal.LinkedTreeMap cannot be cast to xxx

先看下返回的Json数据格式

{
    "code": 200,
    "data": [
        {
            "id": null,
            "type": "free",
            "name": "免费数字教材",
            "totals": null,
            "books": [
                {
                    "ebook_type": "0",
                    "author": "测试作者",
                    "isfree": "0",
                    "isbn": "9787040144390",
                    "title": "测试标题1",
                    "type": 0,
                    "url": "http://d7.ixdzs.com/66/66746/66746.epub",
                    "download_count": 234,
                    "cover": "https://pic4.zhimg.com/017d7c47843b8816a0ab583d37628947_xld.jpg",
                    "addtime": 1493869462000,
                    "id": 4,
                    "press": "测试出版社",
                    "introduction": "简介",
                    "likes": 1
                }
                ...
            ]
        }
    ],
    "msg": "ok",
    "app_key": 
;