【发布时间】:2016-02-25 02:59:41
【问题描述】:
如何调整 Retrofit 2.0 以根据服务器响应调用正确的模型。
即成功返回 Json
{
"status": "successful",
"session_id": "123",
}
即失败的 Json 返回
{
"status": "fail",
"message": "Wrong Email",
}
我使用http://www.jsonschema2pojo.org 创建了登录模型。
然后我打电话给
@FormUrlEncoded
@POST(Constant.API_LOGIN)
Call<UserLogIn> userLogin(@FieldMap Map<String, String> params);
但如果登录失败,我需要使用这个:?
@FormUrlEncoded
@POST(Constant.API_LOGIN)
Call<UserLogInFalied> userLogin(@FieldMap Map<String, String> params);
我只需要 GSON 将响应映射到正确的模型? 任何建议如何克服这个/ 谢谢。
【问题讨论】:
标签: android json gson retrofit androidhttpclient