为什么GSON不能读取JSON对象的JSON数组?

atmip9wb  于 2022-11-06  发布在  其他
关注(0)|答案(1)|浏览(236)

我尝试将一个JSON对象(使用GSON库)转换为一个类。JSON数据的结构如下:

{
    "warFrequency": "never",
    "warLeague": {
        "name": "Master League I",
        "id": 48000015
    },
    "requiredVersusTrophies": 3800,
    "requiredTownhallLevel": 14,
    "warWins": 361,
    "warWinStreak": 1,
    "clanLevel": 20,
    "requiredTrophies": 4300,
    "description": "Special trainer, no need to thanks!",
    "badgeUrls": {
        "small": "https://api-assets.clashofclans.com/badges/70/YlhOqzPXmKUGztQrJjm9nBhZFGim56VNbCUsWCMPQrg.png",
        "large": "https://api-assets.clashofclans.com/badges/512/YlhOqzPXmKUGztQrJjm9nBhZFGim56VNbCUsWCMPQrg.png",
        "medium": "https://api-assets.clashofclans.com/badges/200/YlhOqzPXmKUGztQrJjm9nBhZFGim56VNbCUsWCMPQrg.png"
    },
    "isWarLogPublic": false,
    "type": "closed",
    "chatLanguage": {
        "name": "?????±????",
        "id": 75000015,
        "languageCode": "FA"
    },
    "clanPoints": 40552,
    "labels": [
        {
            "name": "Clan War League",
            "iconUrls": {
                "small": "https://api-assets.clashofclans.com/labels/64/5w60_3bdtYUe9SM6rkxBRyV_8VvWw_jTlDS5ieU3IsI.png",
                "medium": "https://api-assets.clashofclans.com/labels/128/5w60_3bdtYUe9SM6rkxBRyV_8VvWw_jTlDS5ieU3IsI.png"
            },
            "id": 56000001
        },
        {
            "name": "Builder Base",
            "iconUrls": {
                "small": "https://api-assets.clashofclans.com/labels/64/kyuaiAWdnD9v3ReYPS3_x6QP3V3e0nNAPyDroOIDFZQ.png",
                "medium": "https://api-assets.clashofclans.com/labels/128/kyuaiAWdnD9v3ReYPS3_x6QP3V3e0nNAPyDroOIDFZQ.png"
            },
            "id": 56000005
        },
        {
            "name": "Base Designing",
            "iconUrls": {
                "small": "https://api-assets.clashofclans.com/labels/64/LG966XuC6YoEJsPthcgtyJ8uS46LqYDAeiHJNQKR3YQ.png",
                "medium": "https://api-assets.clashofclans.com/labels/128/LG966XuC6YoEJsPthcgtyJ8uS46LqYDAeiHJNQKR3YQ.png"
            },
            "id": 56000006
        }
    ],
    "memberList": [
        {
            "donationsReceived": 8104,
            "clanRank": 1,
            "previousClanRank": 1,
            "role": "coLeader",
            "donations": 1172,
            "league": {
                "name": "Legend League",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/R2zmhyqQ0_lKcDR5EyghXCxgyC9mm_mVMIjAbmGoZtw.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/R2zmhyqQ0_lKcDR5EyghXCxgyC9mm_mVMIjAbmGoZtw.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/R2zmhyqQ0_lKcDR5EyghXCxgyC9mm_mVMIjAbmGoZtw.png"
                },
                "id": 29000022
            },
            "name": "hard heart",
            "expLevel": 251,
            "tag": "#8YRRJLL2G",
            "trophies": 5689,
            "versusTrophies": 5029
        },
        {
            "donationsReceived": 2336,
            "clanRank": 2,
            "previousClanRank": 4,
            "role": "coLeader",
            "donations": 177,
            "league": {
                "name": "Legend League",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/R2zmhyqQ0_lKcDR5EyghXCxgyC9mm_mVMIjAbmGoZtw.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/R2zmhyqQ0_lKcDR5EyghXCxgyC9mm_mVMIjAbmGoZtw.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/R2zmhyqQ0_lKcDR5EyghXCxgyC9mm_mVMIjAbmGoZtw.png"
                },
                "id": 29000022
            },
            "name": "FighteRâ? HEkMaT",
            "expLevel": 245,
            "tag": "#9LLVV8JR2",
            "trophies": 5480,
            "versusTrophies": 5185
        },
        {
            "donationsReceived": 3772,
            "clanRank": 3,
            "previousClanRank": 3,
            "role": "coLeader",
            "donations": 278,
            "league": {
                "name": "Legend League",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/R2zmhyqQ0_lKcDR5EyghXCxgyC9mm_mVMIjAbmGoZtw.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/R2zmhyqQ0_lKcDR5EyghXCxgyC9mm_mVMIjAbmGoZtw.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/R2zmhyqQ0_lKcDR5EyghXCxgyC9mm_mVMIjAbmGoZtw.png"
                },
                "id": 29000022
            },

            },
            "name": "king rahmat",
            "expLevel": 210,
            "tag": "#YQR99V908",
            "trophies": 4079,
            "versusTrophies": 5819
        },
        {
            "donationsReceived": 78,
            "clanRank": 13,
            "previousClanRank": 0,
            "role": "member",
            "donations": 0,
            "league": {
                "name": "Titan League III",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/L-HrwYpFbDwWjdmhJQiZiTRa_zXPPOgUTdmbsaq4meo.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/L-HrwYpFbDwWjdmhJQiZiTRa_zXPPOgUTdmbsaq4meo.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/L-HrwYpFbDwWjdmhJQiZiTRa_zXPPOgUTdmbsaq4meo.png"
                },
                "id": 29000019
            },
            "name": "King Shokur (2)",
            "expLevel": 123,
            "tag": "#Q0VVGPYRR",
            "trophies": 3400,
            "versusTrophies": 2526
        },
        {
            "donationsReceived": 199,
            "clanRank": 22,
            "previousClanRank": 21,
            "role": "coLeader",
            "donations": 79,
            "league": {
                "name": "Champion League III",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/JmmTbspV86xBigM7OP5_SjsEDPuE7oXjZC9aOy8xO3s.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/JmmTbspV86xBigM7OP5_SjsEDPuE7oXjZC9aOy8xO3s.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/JmmTbspV86xBigM7OP5_SjsEDPuE7oXjZC9aOy8xO3s.png"
                },
                "id": 29000016
            },
            "name": "slash 19 R",
            "expLevel": 202,
            "tag": "#YRP9CGQ9Q",
            "trophies": 3335,
            "versusTrophies": 5706
        },
        {
            "donationsReceived": 1234,
            "clanRank": 23,
            "previousClanRank": 23,
            "role": "coLeader",
            "donations": 333,
            "league": {
                "name": "Master League I",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png"
                },
                "id": 29000015
            },
            "name": "GeNRal Reshad",
            "expLevel": 231,
            "tag": "#8RP89JC9G",
            "trophies": 3062,
            "versusTrophies": 5180
        },
        {
            "donationsReceived": 936,
            "clanRank": 24,
            "previousClanRank": 25,
            "role": "coLeader",
            "donations": 1598,
            "league": {
                "name": "Master League I",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png"
                },
                "id": 29000015
            },
            "name": "Shabir Kirok",
            "expLevel": 145,
            "tag": "#9289GVRVC",
            "trophies": 3026,
            "versusTrophies": 2985
        },
        {
            "donationsReceived": 0,
            "clanRank": 25,
            "previousClanRank": 22,
            "role": "member",
            "donations": 45,
            "league": {
                "name": "Master League I",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png"
                },
                "id": 29000015
            },
            "name": "�ive � Li��",
            "expLevel": 186,
            "tag": "#P9PRCRYVG",
            "trophies": 3003,
            "versusTrophies": 6200
        },
        {
            "donationsReceived": 0,
            "clanRank": 26,
            "previousClanRank": 24,
            "role": "member",
            "donations": 0,
            "league": {
                "name": "Master League I",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/olUfFb1wscIH8hqECAdWbdB6jPm9R8zzEyHIzyBgRXc.png"
                },
                "id": 29000015
            },
            "name": "GeNRal Rahmat",
            "expLevel": 201,
            "tag": "#2VVGPY0JU",
            "trophies": 2977,
            "versusTrophies": 5032
        },
        {
            "donationsReceived": 0,
            "clanRank": 27,
            "previousClanRank": 26,
            "role": "coLeader",
            "donations": 0,
            "league": {
                "name": "Unranked",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png"
                },
                "id": 29000000
            },
            "name": "Æ’ighter",
            "expLevel": 218,
            "tag": "#99CY0RCGV",
            "trophies": 2952,
            "versusTrophies": 5053
        },
        {
            "donationsReceived": 75,
            "clanRank": 28,
            "previousClanRank": 27,
            "role": "member",
            "donations": 1029,
            "league": {
                "name": "Master League III",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/pSXfKvBKSgtvfOY3xKkgFaRQi0WcE28s3X35ywbIluY.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/pSXfKvBKSgtvfOY3xKkgFaRQi0WcE28s3X35ywbIluY.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/pSXfKvBKSgtvfOY3xKkgFaRQi0WcE28s3X35ywbIluY.png"
                },
                "id": 29000013
            },
            "name": "â? SɪÆ? Vɪá?„á?›á???€â? ï??",
            "expLevel": 206,
            "tag": "#9UL0RJCCR",
            "trophies": 2678,
            "versusTrophies": 3880
        },
        {
            "donationsReceived": 270,
            "clanRank": 29,
            "previousClanRank": 28,
            "role": "member",
            "donations": 1,
            "league": {
                "name": "Crystal League I",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/kSfTyNNVSvogX3dMvpFUTt72VW74w6vEsEFuuOV4osQ.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/kSfTyNNVSvogX3dMvpFUTt72VW74w6vEsEFuuOV4osQ.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/kSfTyNNVSvogX3dMvpFUTt72VW74w6vEsEFuuOV4osQ.png"
                },
                "id": 29000012
            },
            "name": "khalil jan",
            "expLevel": 119,
            "tag": "#YGUR2JCGG",
            "trophies": 2369,
            "versusTrophies": 2835
        },
        {
            "donationsReceived": 263,
            "clanRank": 30,
            "previousClanRank": 30,
            "role": "member",
            "donations": 1,
            "league": {
                "name": "Crystal League II",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/jhP36EhAA9n1ADafdQtCP-ztEAQjoRpY7cT8sU7SW8A.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/jhP36EhAA9n1ADafdQtCP-ztEAQjoRpY7cT8sU7SW8A.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/jhP36EhAA9n1ADafdQtCP-ztEAQjoRpY7cT8sU7SW8A.png"
                },
                "id": 29000011
            },
            "name": "ERORR[404]",
            "expLevel": 116,
            "tag": "#YUL2L9CUU",
            "trophies": 2255,
            "versusTrophies": 3112
        },
        {
            "donationsReceived": 45,
            "clanRank": 31,
            "previousClanRank": 29,
            "role": "member",
            "donations": 166,
            "league": {
                "name": "Crystal League II",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/jhP36EhAA9n1ADafdQtCP-ztEAQjoRpY7cT8sU7SW8A.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/jhP36EhAA9n1ADafdQtCP-ztEAQjoRpY7cT8sU7SW8A.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/jhP36EhAA9n1ADafdQtCP-ztEAQjoRpY7cT8sU7SW8A.png"
                },
                "id": 29000011
            },
            "name": "Ä???PÅ???MÄ„Å?",
            "expLevel": 186,
            "tag": "#88V9V9G2G",
            "trophies": 2167,
            "versusTrophies": 2970
        },
        {
            "donationsReceived": 97,
            "clanRank": 32,
            "previousClanRank": 31,
            "role": "member",
            "donations": 1695,
            "league": {
                "name": "Crystal League II",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/jhP36EhAA9n1ADafdQtCP-ztEAQjoRpY7cT8sU7SW8A.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/jhP36EhAA9n1ADafdQtCP-ztEAQjoRpY7cT8sU7SW8A.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/jhP36EhAA9n1ADafdQtCP-ztEAQjoRpY7cT8sU7SW8A.png"
                },
                "id": 29000011
            },
            "name": "Ä?ĂŃÄ??‹R",
            "expLevel": 145,
            "tag": "#Y2J8G82JJ",
            "trophies": 2159,
            "versusTrophies": 3135
        },
        {
            "donationsReceived": 938,
            "clanRank": 33,
            "previousClanRank": 33,
            "role": "coLeader",
            "donations": 0,
            "league": {
                "name": "Crystal League III",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/Hyqco7bHh0Q81xB8mSF_ZhjKnKcTmJ9QEq9QGlsxiKE.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/Hyqco7bHh0Q81xB8mSF_ZhjKnKcTmJ9QEq9QGlsxiKE.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/Hyqco7bHh0Q81xB8mSF_ZhjKnKcTmJ9QEq9QGlsxiKE.png"
                },
                "id": 29000010
            },
            "name": "Murtaza KiroK",
            "expLevel": 92,
            "tag": "#LQR2Q2UPL",
            "trophies": 2073,
            "versusTrophies": 2122
        },
        {
            "donationsReceived": 65,
            "clanRank": 34,
            "previousClanRank": 32,
            "role": "member",
            "donations": 33,
            "league": {
                "name": "Unranked",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png"
                },
                "id": 29000000
            },
            "name": "Husna jahangirâ??",
            "expLevel": 169,
            "tag": "#99PGLGC9J",
            "trophies": 2038,
            "versusTrophies": 2636
        },
        {
            "donationsReceived": 0,
            "clanRank": 35,
            "previousClanRank": 34,
            "role": "coLeader",
            "donations": 1751,
            "league": {
                "name": "Unranked",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png"
                },
                "id": 29000000
            },
            "name": "��庄�",
            "expLevel": 153,
            "tag": "#Y9VYURQGP",
            "trophies": 1998,
            "versusTrophies": 3103
        },
        {
            "donationsReceived": 0,
            "clanRank": 36,
            "previousClanRank": 35,
            "role": "member",
            "donations": 1354,
            "league": {
                "name": "Unranked",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png"
                },
                "id": 29000000
            },
            "name": "â?¡KiNG ERFANâ??",
            "expLevel": 149,
            "tag": "#PC0GGYC9L",
            "trophies": 1945,
            "versusTrophies": 1739
        },
        {
            "donationsReceived": 0,
            "clanRank": 37,
            "previousClanRank": 36,
            "role": "admin",
            "donations": 1557,
            "league": {
                "name": "Gold League I",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/CorhMY9ZmQvqXTZ4VYVuUgPNGSHsO0cEXEL5WYRmB2Y.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/CorhMY9ZmQvqXTZ4VYVuUgPNGSHsO0cEXEL5WYRmB2Y.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/CorhMY9ZmQvqXTZ4VYVuUgPNGSHsO0cEXEL5WYRmB2Y.png"
                },
                "id": 29000009
            },
            "name": "Ä?ĂŃÄ??‹R",
            "expLevel": 100,
            "tag": "#Y8RJV0JC0",
            "trophies": 1827,
            "versusTrophies": 1777
        },
        {
            "donationsReceived": 32,
            "clanRank": 38,
            "previousClanRank": 37,
            "role": "admin",
            "donations": 66,
            "league": {
                "name": "Gold League II",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/Y6CveuHmPM_oiOic2Yet0rYL9AFRYW0WA0u2e44-YbM.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/Y6CveuHmPM_oiOic2Yet0rYL9AFRYW0WA0u2e44-YbM.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/Y6CveuHmPM_oiOic2Yet0rYL9AFRYW0WA0u2e44-YbM.png"
                },
                "id": 29000008
            },
            "name": "â?…??Æ??£???ï?‘ï½²â????â? ",
            "expLevel": 154,
            "tag": "#P2Q9RP9R0",
            "trophies": 1638,
            "versusTrophies": 1970
        },
        {
            "donationsReceived": 0,
            "clanRank": 39,
            "previousClanRank": 38,
            "role": "admin",
            "donations": 2,
            "league": {
                "name": "Gold League III",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/vd4Lhz5b2I1P0cLH25B6q63JN3Wt1j2NTMhOYpMPQ4M.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/vd4Lhz5b2I1P0cLH25B6q63JN3Wt1j2NTMhOYpMPQ4M.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/vd4Lhz5b2I1P0cLH25B6q63JN3Wt1j2NTMhOYpMPQ4M.png"
                },
                "id": 29000007
            },
            "name": "ä?ƒ?„¥?„–?„–Ä??„? å??å?‚å°ºå‡ å?‚Ä¢ä?‡!",
            "expLevel": 77,
            "tag": "#L9QP90LU2",
            "trophies": 1460,
            "versusTrophies": 3101
        },
        {
            "donationsReceived": 0,
            "clanRank": 40,
            "previousClanRank": 0,
            "role": "member",
            "donations": 0,
            "league": {
                "name": "Gold League III",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/vd4Lhz5b2I1P0cLH25B6q63JN3Wt1j2NTMhOYpMPQ4M.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/vd4Lhz5b2I1P0cLH25B6q63JN3Wt1j2NTMhOYpMPQ4M.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/vd4Lhz5b2I1P0cLH25B6q63JN3Wt1j2NTMhOYpMPQ4M.png"
                },
                "id": 29000007
            },
            "name": "Michael Jackson",
            "expLevel": 65,
            "tag": "#QRQRJVV0Y",
            "trophies": 1452,
            "versusTrophies": 2071
        },
        {
            "donationsReceived": 0,
            "clanRank": 41,
            "previousClanRank": 0,
            "role": "member",
            "donations": 0,
            "league": {
                "name": "Silver League I",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/nvrBLvCK10elRHmD1g9w5UU1flDRMhYAojMB2UbYfPs.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/nvrBLvCK10elRHmD1g9w5UU1flDRMhYAojMB2UbYfPs.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/nvrBLvCK10elRHmD1g9w5UU1flDRMhYAojMB2UbYfPs.png"
                },
                "id": 29000006
            },
            "name": "Don Jon",
            "expLevel": 62,
            "tag": "#QJ0GPURY8",
            "trophies": 1365,
            "versusTrophies": 2046
        },
        {
            "donationsReceived": 2,
            "clanRank": 42,
            "previousClanRank": 39,
            "role": "admin",
            "donations": 0,
            "league": {
                "name": "Silver League I",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/nvrBLvCK10elRHmD1g9w5UU1flDRMhYAojMB2UbYfPs.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/nvrBLvCK10elRHmD1g9w5UU1flDRMhYAojMB2UbYfPs.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/nvrBLvCK10elRHmD1g9w5UU1flDRMhYAojMB2UbYfPs.png"
                },
                "id": 29000006
            },
            "name": "Ä?ĂŃÄ??‹R",
            "expLevel": 75,
            "tag": "#928YJYUYR",
            "trophies": 1219,
            "versusTrophies": 827
        },
        {
            "donationsReceived": 0,
            "clanRank": 43,
            "previousClanRank": 40,
            "role": "admin",
            "donations": 0,
            "league": {
                "name": "Unranked",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png"
                },
                "id": 29000000
            },
            "name": "â?†mansorâ?†",
            "expLevel": 65,
            "tag": "#Y2UQUUGP9",
            "trophies": 1132,
            "versusTrophies": 1750
        },
        {
            "donationsReceived": 150,
            "clanRank": 44,
            "previousClanRank": 41,
            "role": "admin",
            "donations": 0,
            "league": {
                "name": "Silver League III",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/QcFBfoArnafaXCnB5OfI7vESpQEBuvWtzOyLq8gJzVc.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/QcFBfoArnafaXCnB5OfI7vESpQEBuvWtzOyLq8gJzVc.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/QcFBfoArnafaXCnB5OfI7vESpQEBuvWtzOyLq8gJzVc.png"
                },
                "id": 29000004
            },
            "name": "Ä?ĂŃÄ??‹R",
            "expLevel": 36,
            "tag": "#Y2YGY899U",
            "trophies": 771,
            "versusTrophies": 321
        },
        {
            "donationsReceived": 280,
            "clanRank": 45,
            "previousClanRank": 42,
            "role": "coLeader",
            "donations": 0,
            "league": {
                "name": "Silver League III",
                "iconUrls": {
                    "small": "https://api-assets.clashofclans.com/leagues/72/QcFBfoArnafaXCnB5OfI7vESpQEBuvWtzOyLq8gJzVc.png",
                    "tiny": "https://api-assets.clashofclans.com/leagues/36/QcFBfoArnafaXCnB5OfI7vESpQEBuvWtzOyLq8gJzVc.png",
                    "medium": "https://api-assets.clashofclans.com/leagues/288/QcFBfoArnafaXCnB5OfI7vESpQEBuvWtzOyLq8gJzVc.png"
                },
                "id": 29000004
            },
            "name": "Long live AFG",
            "expLevel": 36,
            "tag": "#QRLUPYCJ9",
            "trophies": 749,
            "versusTrophies": 1313
        }
    ],
    "clanVersusPoints": 49233,
    "members": 45,
    "name": "The wonder boys",
    "location": {
        "isCountry": true,
        "countryCode": "AF",
        "name": "Afghanistan",
        "id": 32000007
    },
    "tag": "#C28P8G0J"
}

家族职业:

public class Clan {
    public String tag;
    public String name;
    public String type;
    public String description;
    public JSONObject location;
    public JSONObject badgeUrls;
    public int clanLevel;
    public int clanPoints;
    public int requiredTrophies;
    public String warFrequency;
    public int warWinStreak;
    public int warWins;
    public boolean isWarLogPublic;
    public JSONObject warLeague;
    public int members;
    public JSONArray membersList;
    public JSONArray labels;
    public JSONObject chatLanguage;
    public int requiredVersusTrophies;
    public int requiredTownHallLevel;
}

JSON到氏族类代码:

InputStream content = (InputStream)connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
JSONTokener tokener = new JSONTokener(reader);
JSONObject clanJObject = new JSONObject(tokener);
String strOfJSON = clanJObject.toString();
Gson gson = new Gson();
Clan clan = gson.fromJson(strOfJSON, Clan.class);

问题:

当我运行程序时,收到以下错误信息:
BEGIN_OBJECT
在此之后,我尝试将我的clan类中的label变量更改为JSONObject,因为错误声明它需要一个BEGIN_OBJECT。然而,当我再次运行程序时,我得到错误消息:
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 935 path $.labels
我已经检查了JSON,标签和成员列表是唯一的JSON数组,所以我不太清楚为什么会有错误。我在我的氏族类中设置的变量正确吗?任何帮助都非常感谢:)

fdx2calv

fdx2calv1#

为JSON的所有嵌套结构创建单独的类,例如,对于JSON中的labels,应该有一个对应的类

public class Label {
    public String name;
    public List<String> iconUrls;
    public String id;
}

然后将Clan类中的labels的类型更改为List<Label>

相关问题