0

I am new start with Retrofit when i am trying to get data form api use Retrofit2 + Rxjava:

ApiService:

@GET("news/get_comments/{newsid}/{count}/{offset}")
Observable<ResultResponse<CommentList>> getComment(@Header("api_key") String key, @Path("newsid") String newsid, @Path("count")String count, @Path("offset")String offset);

public void getComment(String item_id, int pageNow) {
        int offset = (pageNow - 1) * 10;
        Log.i("commentlist", offset+"");
        Log.i("commentlist",pageNow+"");
        addSubscription(AppClient.getApiService().getComment(ApiService.KEY,item_id,"10",offset+""), new SubscriberCallBack<CommentList>() {
            @Override
            protected void onSuccess(CommentList response) {
                Logger.i("commentist",response.toString());
                mvpView.onGetCommentSuccess(response);
            }

        });
    }

GSON throwing an error:com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 41 path $.data

Community
  • 1
  • 1
Wang Jian
  • 321
  • 5
  • 20

1 Answers1

1

this is because your response starts with [] not {} actually you are getting a jsonarray instead of jsonobject

kamran hatami
  • 122
  • 1
  • 8