假设我有这个虚拟API
@POST("somepath/setSomething")
Call<ExecuteResponse> setSomething(@Body ExecuteInput input);
和此回叫
Callback<ExecuteResponse> callBack = new Callback<ExecuteResponse>() {
@Override
public void onResponse(Call<ExecuteResponse> call, Response<ExecuteResponse> response) {};
如何访问调用的正文并取回ExecuteInput对象?
答案 0 :(得分:0)
您可以执行response.getBody()
,然后将在Response<???>
中获得指定的对象。在这种情况下,ExecuteResponse
。
当然,我想您已经在对象内部定义了@SerializedName
,或者在ExecuteResponse
模型类中定义了正确的字段名称。