Java 我能';t通过改装从Kitsu Api获得动画列表

Java 我能';t通过改装从Kitsu Api获得动画列表,java,android,gson,retrofit,Java,Android,Gson,Retrofit,我得到了以下错误:com.google.gson.JsonSyntaxException:java.lang.IllegalStateException:应为BEGIN_对象,但在第1行第10列path$.data处为BEGIN_数组 RetroService RetroService=RetroInstance.getRefundation().create(RetroService.class) 基本上应该是BEGIN\u对象,但是BEGIN\u ARRAY意味着您尝试解析单个对象(Ani

我得到了以下错误:com.google.gson.JsonSyntaxException:java.lang.IllegalStateException:应为BEGIN_对象,但在第1行第10列path$.data处为BEGIN_数组

RetroService RetroService=RetroInstance.getRefundation().create(RetroService.class)


基本上
应该是BEGIN\u对象,但是BEGIN\u ARRAY
意味着您尝试解析单个对象(
Animes
),虽然JSON中没有单个对象,但它是一个数组(根)

不知道您的
RetroInstance
RetroService
是如何工作的,但是:

Call<Animes> call = ...
Call=。。。
应该是

Call<ArrayList<Data>> call = ...
Call=。。。

在询问与json相关的问题时,您是否也可以将您将收到的json包含在问题中(以文本形式)-它只会帮助其他人解决问题,因为它是链接在question@snachmsm当然,但是如果链接中的json发生了变化,并且不是每个人都想点击外部链接,那么这就没用了,这让我很恼火,我试图这么做,但错误变为:java.lang.IllegalStateException:应为BEGIN_数组,但在第1行第2列路径$RetroInstance:private static Reformation处为BEGIN_对象;公共静态改装getReformation(){if(Reformation==null){Reformation=new Reformation.Builder().baseUrl(“).addConverterFactory(GsonConverterFactory.create()).build();}返回改装;}
    @Expose
    private Data data;

    /**
     * No args constructor for use in serialization
     *
     */
    public Animes() {
    }

    /**
     *
     * @param data
     */
    public Animes(Data data) {
        super();
        this.data = data;
    }

    public Data getData() {
        return data;
    }

    public void setData(Data data) {
        this.data = data;
    }



public class Data {

    @SerializedName("id")
    @Expose
    private String id;
    @SerializedName("type")
    @Expose
    private String type;
    @SerializedName("attributes")
    @Expose
    private Attributes attributes;


    //With  getter and setters and constructor

public class Attributes {
    @SerializedName("synopsis")
    @Expose
    private String synopsis;
    @SerializedName("canonicalTitle")
    @Expose
    private String canonicalTitle;
    @SerializedName("startDate")
    @Expose
    private String startDate;
    @SerializedName("endDate")
    @Expose
    private String endDate;
    @SerializedName("ratingRank")
    @Expose
    private Integer ratingRank;
    @SerializedName("status")
    @Expose
    private String status;
    @SerializedName("episodeCount")
    @Expose
    private Integer episodeCount;
    @SerializedName("youtubeVideoId")
    @Expose
    private String youtubeVideoId;
//With  getter and setters and constructor
Call<Animes> call = ...
Call<ArrayList<Data>> call = ...