2 回答
TA贡献1797条经验 获得超6个赞
您已声明错误的 API URL 是:
public static final String BASE_URL = "https://api.jikan.moe/v3/";
你MainResponse应该是这样的:
public class MainResponse {
@SerializedName("request_hash")
@Expose
private String requestHash;
@SerializedName("request_cached")
@Expose
private Boolean requestCached;
@SerializedName("request_cache_expiry")
@Expose
private Integer requestCacheExpiry;
@SerializedName("monday")
@Expose
private List<Monday> monday = null;
public String getRequestHash() {
return requestHash;
}
public void setRequestHash(String requestHash) {
this.requestHash = requestHash;
}
public Boolean getRequestCached() {
return requestCached;
}
public void setRequestCached(Boolean requestCached) {
this.requestCached = requestCached;
}
public Integer getRequestCacheExpiry() {
return requestCacheExpiry;
}
public void setRequestCacheExpiry(Integer requestCacheExpiry) {
this.requestCacheExpiry = requestCacheExpiry;
}
public List<Monday> getMonday() {
return monday;
}
public void setMonday(List<Monday> monday) {
this.monday = monday;
}
}
该Genre班
public class Genre {
@SerializedName("mal_id")
@Expose
private Integer malId;
@SerializedName("type")
@Expose
private String type;
@SerializedName("name")
@Expose
private String name;
@SerializedName("url")
@Expose
private String url;
public Integer getMalId() {
return malId;
}
public void setMalId(Integer malId) {
this.malId = malId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
最后是Monday班级
public class Monday {
@SerializedName("mal_id")
@Expose
private Integer malId;
@SerializedName("url")
@Expose
private String url;
@SerializedName("title")
@Expose
private String title;
@SerializedName("image_url")
@Expose
private String imageUrl;
@SerializedName("synopsis")
@Expose
private String synopsis;
@SerializedName("type")
@Expose
private String type;
@SerializedName("airing_start")
@Expose
private String airingStart;
@SerializedName("episodes")
@Expose
private Integer episodes;
@SerializedName("members")
@Expose
private Integer members;
@SerializedName("genres")
@Expose
private List<Genre> genres = null;
@SerializedName("source")
@Expose
private String source;
@SerializedName("producers")
@Expose
private List<Object> producers = null;
@SerializedName("score")
@Expose
private Object score;
@SerializedName("licensors")
@Expose
private List<Object> licensors = null;
@SerializedName("r18")
@Expose
private Boolean r18;
@SerializedName("kids")
@Expose
private Boolean kids;
public Integer getMalId() {
return malId;
}
public void setMalId(Integer malId) {
this.malId = malId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getSynopsis() {
return synopsis;
}
public void setSynopsis(String synopsis) {
this.synopsis = synopsis;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getAiringStart() {
return airingStart;
}
public void setAiringStart(String airingStart) {
this.airingStart = airingStart;
}
public Integer getEpisodes() {
return episodes;
}
public void setEpisodes(Integer episodes) {
this.episodes = episodes;
}
public Integer getMembers() {
return members;
}
public void setMembers(Integer members) {
this.members = members;
}
public List<Genre> getGenres() {
return genres;
}
public void setGenres(List<Genre> genres) {
this.genres = genres;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public List<Object> getProducers() {
return producers;
}
public void setProducers(List<Object> producers) {
this.producers = producers;
}
public Object getScore() {
return score;
}
public void setScore(Object score) {
this.score = score;
}
public List<Object> getLicensors() {
return licensors;
}
public void setLicensors(List<Object> licensors) {
this.licensors = licensors;
}
public Boolean getR18() {
return r18;
}
public void setR18(Boolean r18) {
this.r18 = r18;
}
public Boolean getKids() {
return kids;
}
public void setKids(Boolean kids) {
this.kids = kids;
}
}
TA贡献1835条经验 获得超7个赞
您的 api 链接是https://api.jikan.moe/v3/schedule 但在您编写的代码中
public static final String BASE_URL = "http://api.themoviedb.org/3/";
您可以将基本 url 更改为https://api.jikan.moe/v3/,或者
在 getSchedule() 的 GET 注释上提供完整的 url
@GET("https://api.jikan.moe/v3/schedule")
Call<MainResponse> getSchedule();
添加回答
举报