I cannot get response. Every time it says Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 11 path $.total. I am new in Android. I have tried lots of solutions but not worked. Here is the response from server -
{
"total": {
"confirmed": 38292,
"recovered": 7925,
"deaths": 544,
"tested": 266509
},
"last": {
"tested": "8015",
"confirmed": "1541",
"recovered": "346",
"deaths": "22"
},
"lastUpdate": "Wednesday, 27 May, 2020 03:32PM"
}
Here is my model -
public class Stat {
private List<Total> total;
private List<Last> last;
private String lastUpdate;
public List<Total> getTotal() {
return total;
}
public void setTotal(List<Total> total) {
this.total = total;
}
public List<Last> getLast() {
return last;
}
public void setLast(List<Last> last) {
this.last = last;
}
public String getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(String lastUpdate) {
this.lastUpdate = lastUpdate;
}
}
Here is my activity -
ApiInterface apiInterface = ApiClient.getApiClient().create(ApiInterface.class);
Call<Stat> call = apiInterface.getStats();
call.enqueue(new Callback<Stat>() {
@Override
public void onResponse(Call<Stat> call, Response<Stat> response) {
progressDialog.dismiss();
if (response.isSuccessful()) {
int code = response.code();
Log.i("code ", Integer.toString(code));
}
}
@Override
public void onFailure(Call<Stat> call, Throwable t) {
progressDialog.dismiss();
Log.i("error ", t.getMessage());
}
});
Here is my interface -
@GET("stats")
Call<Stat> getStats();