2017-07-07 116 views
0

我新的开始与改造,当我试图让数据的形式API使用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抛出一个错误:com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 41 path $.data

+0

添加你要回来的JSON。另外,添加你创建的ResultResponse和CommentList对象 – TooManyEduardos

回答

1

这是因为你的回应[]开始时,没有{}实际上你得到一个jsonarray代替的JSONObject

+0

是的兄弟你是正确的thx –

相关问题