带有RIOT API的Google API JSON解析失败

时间:2018-08-08 08:13:05

标签: java api google-api

有人可以帮我吗?

Exception in thread "main" net.rithms.riot.api.RiotApiException: Failed to parse the JSON response
at net.rithms.riot.api.request.Request.getDto(Request.java:288)
at net.rithms.riot.api.request.Request.getDto(Request.java:252)
at net.rithms.riot.api.EndpointManager.callMethodAndReturnDto(EndpointManager.java:53)
at net.rithms.riot.api.RiotApi.getLeagueById(RiotApi.java:1467)
at lol.simone.pescatore.riot.App.main(App.java:28)

此错误是由Google API在此处触发的:

package lol.simone.pescatore.riot;

import java.util.List;

import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.RiotApi;
import net.rithms.riot.api.RiotApiException;
import net.rithms.riot.api.endpoints.league.dto.LeagueItem;
import net.rithms.riot.api.endpoints.match.dto.Match;
import net.rithms.riot.api.endpoints.match.dto.MatchList;
import net.rithms.riot.api.endpoints.match.dto.MatchReference;
import net.rithms.riot.api.endpoints.match.dto.TeamBans;
import net.rithms.riot.api.endpoints.match.dto.TeamStats;
import net.rithms.riot.api.endpoints.summoner.dto.Summoner;
import net.rithms.riot.constant.Platform;

//  lega -> lista summoner della lega -> summoner -> lista match del summoner -> dal match prendo le match references -> prendo anche i partecipanti -> prendo tutte le statistiche dal match -> butto tutto nel CSV

public class App {

    public static final String CSV_PATH = "C:\\Users\\gzampaol\\Lol";

    public static void main(String[] args) throws RiotApiException {
        ApiConfig config = new ApiConfig().setKey("RGAPI-92701727-09f4-4e68-8c75-c903715fb112S");
        RiotApi api = new RiotApi(config);


        List<LeagueItem> participant = api.getLeagueById(Platform.EUW, "000115d0-45ad-11e8-a09c-c81f66dbb56c").getEntries();
        MatchList matchList = new MatchList();
        String mapName = new String();
        TeamBans bans = new TeamBans();

坏了

List<LeagueItem> participant = api.getLeagueById(Platform.EUW, "000115d0-45ad-11e8-a09c-c81f66dbb56c").getEntries();

这就是我发现的

java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

我将Eclipse与JDK一起使用,而我正在使用com.google.code.gson v2.8.5

身体反应:https://pastebin.com/ac3d6sRL

错误在这里产生

dto = new Gson().fromJson(response.getBody(), type);

我该如何解决?

(附言。我是自学成才的,所以我不知道很多事情。请尽可能露骨。谢谢您<3)

0 个答案:

没有答案