Я знаю, что это не первый раз, когда кто-то спрашивал про эту проблему, но с Retrofit2 я не могу найти правильное решение моей проблемы. Получаю следующую ошибку: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
Base_URL данные беру из этого сайт
Interface:
public interface RetrofitService {
@GET("entries/count")
Call<List<JsonModel>> getJsonList();
}
StartApplication:
public class StartApplication extends Application {
private final String BASE_URL = "https://api.publicapis.org/";
private RetrofitService service;
@Override
public void onCreate() {
super.onCreate();
service = initRetrofit();
}
public static StartApplication get(Context context) {
return (StartApplication) context.getApplicationContext();
}
public RetrofitService getRetrofitClient(){
return service;
}
private RetrofitService initRetrofit() {
return new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(RetrofitService.class);
}
}
Собственно метод:
private void setRequest() {
RetrofitService service = StartApplication.get(this).getRetrofitClient();
Call<List<JsonModel>> call = service.getJsonList();
call.enqueue(new Callback<List<JsonModel>>() {
@Override
public void onResponse(Call<List<JsonModel>> call, Response<List<JsonModel>> response) {
}
@Override
public void onFailure(Call<List<JsonModel>> call, Throwable t) {
Log.d("Error", t.getMessage());
}
});
}
Model JsonModel:
public class JsonModel {
@SerializedName("API")
@Expose
private String aPI;
@SerializedName("Description")
@Expose
private String description;
@SerializedName("Auth")
@Expose
private String auth;
@SerializedName("HTTPS")
@Expose
private String hTTPS;
@SerializedName("Cors")
@Expose
private String cors;
@SerializedName("Link")
@Expose
private String link;
@SerializedName("Category")
@Expose
private String category;
//Getter and Setter
CountModel:
public class CountModel {
@SerializedName("count")
@Expose
private int count;
@SerializedName("entries")
@Expose
private List<Map.Entry> entries = null;
Подскажите как исправить ?