I'M using retfofit2 and i have problem with creating model class I cant creat model of this .json file...
I get in throwable wrong com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 12 path $.movies
I think this problem of child "movies": genres
MainActivity
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://server/api/all/")
.addConverterFactory(GsonConverterFactory.create())
.build();
MainInterface mainApi = retrofit.create(MainInterface.class);
Call<MainModel> mainCall = mainApi.getMoviess();
mainCall.enqueue(new Callback<MainModel>() {
@Override
public void onResponse(Call<MainModel> call, Response<MainModel> response) {
Log.d("Retrofittt", "onResponse: ok");
}
@Override
public void onFailure(Call<MainModel> call, Throwable t) {
Log.d("Retrofittt", "onFailure: "+t);
}
});
MainModel
public class MainModel {
private String genre;
private MoviesBean movies;
//getter and setters
public class MoviesBean {
private String content_year;
private String content_id;
private String base_url;
private String base_url_link;
private String content_rating_age;
private String movie_link;
private String content_title;
private String content_text_small;
private String rating_kinopoisk;
private String rating_imdb;
private String rating_kinodelux;
private String link_to_movie;
private String content_poster_small;
private String content_poster;
private GenresBean genres;
///getters and setters
}
public class GenresBean {
private String genre_name;
private String genre_id;
private String base_url_link;
///getters and setters
}
}
MainInterface
interface MainInterface {
@GET("1")
Call<MainModel> getMoviess();
}