3 回答

TA貢獻(xiàn)1839條經(jīng)驗(yàn) 獲得超15個(gè)贊
似乎返回的 JSON 格式不正確(除非您裁剪文件以將其粘貼到此處...)
我使用JSONLint來驗(yàn)證它

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊
僅適用于出現(xiàn)此錯誤的新人。當(dāng)您的數(shù)據(jù)類(模型)與您正在使用的 json 不對應(yīng)時(shí),也會發(fā)生這種情況。
您可以通過將 onResponse() 方法從 Retrofit 設(shè)置為 Any (kotlin) 或?qū)ο?(java) 來驗(yàn)證這一點(diǎn)
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
Log.d("zzz", "debug this line and check if response have ur object");
}

TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個(gè)贊
乍一看,您的 json 似乎有誤,在“video_category”之后還有一個(gè)“,”:“新聞/政治”,<--- 也許這就是問題所在
Btw i would do my pojo like this
我用這個(gè)網(wǎng)站自動創(chuàng)建它http://www.jsonschema2pojo.org/
你總是可以使用這個(gè)網(wǎng)站來驗(yàn)證你的 JSON https://jsonformatter.curiousconcept.com/
-----------------------------------ResponseVideoList.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class ResponseVideoList{
@SerializedName("resonse")
@Expose
private Resonse resonse;
public Resonse getResonse() {
return resonse;
}
public void setResonse(Resonse resonse) {
this.resonse = resonse;
}
}
-----------------------------------Resonse.java-----------------------------------
package com.example;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Resonse {
@SerializedName("status")
@Expose
private Integer status;
@SerializedName("result")
@Expose
private List<Result> result = null;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public List<Result> getResult() {
return result;
}
public void setResult(List<Result> result) {
this.result = result;
}
}
-----------------------------------Result.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Result {
@SerializedName("video_id")
@Expose
private String videoId;
@SerializedName("video_title")
@Expose
private String videoTitle;
@SerializedName("video_description")
@Expose
private String videoDescription;
@SerializedName("video_poster")
@Expose
private String videoPoster;
@SerializedName("video_duration")
@Expose
private String videoDuration;
@SerializedName("video_category")
@Expose
private String videoCategory;
public String getVideoId() {
return videoId;
}
public void setVideoId(String videoId) {
this.videoId = videoId;
}
public String getVideoTitle() {
return videoTitle;
}
public void setVideoTitle(String videoTitle) {
this.videoTitle = videoTitle;
}
public String getVideoDescription() {
return videoDescription;
}
public void setVideoDescription(String videoDescription) {
this.videoDescription = videoDescription;
}
public String getVideoPoster() {
return videoPoster;
}
public void setVideoPoster(String videoPoster) {
this.videoPoster = videoPoster;
}
public String getVideoDuration() {
return videoDuration;
}
public void setVideoDuration(String videoDuration) {
this.videoDuration = videoDuration;
}
public String getVideoCategory() {
return videoCategory;
}
public void setVideoCategory(String videoCategory) {
this.videoCategory = videoCategory;
}
}
添加回答
舉報(bào)