我最近开始使用改造。我不很了解。我用Google搜索这个问题,并没有答案适合我的问题。
I started using Retrofit recently. I don't know much about it. I have googled this issue and no answers suite my problem.
这是JSON响应
{
"results": [
{
"description_eng": "This is second time testing",
"img_url": "-",
"title_eng": "Second test"
},
{
"description_eng": "Hello 1 2 3, I am testing.",
"img_url": "https://m.xsw88.com/allimgs/daicuo/20230903/5760.png.jpg",
"title_eng": "Test"
}
]
}
这是订阅类
public class Feed {
public List<Results> results;
class Results{
String description_eng,img_url,title_eng;
}
}
这是界面
public interface GetApi {
@GET("/api.json")
public void getData(Callback<List<Feed>> response);
}
我 json_illegal_syntax异常
。
这是我如何解决这个问题。
This is how I solved this problem.
Feed.class
Feed.class
public class Feed{
private List<Result> results;
public Feed(){
}
public List<Result> getFeed(){
return this.results;
}
public void setFeed(List<Result> results) {
this.results = results;
}
}
Result.class
Result.class
public class Result{
private String description_eng;
private String img_url;
private String title_eng;
public Result(){}
//getters and setters
}
GetApi.class
GetApi.class
public interface GetApi {
@GET("/api.json")
public void getData(Callback<Feed> response);
}
谢谢回答兄弟。 :D
Thanks for answering bros. :D