LinkedTreeMap cannot be cast Gson

后台返回数据,正常返回data可以,错误返回就为null了 就会出现LinkedTreeMap cannot be cast 这种异常。

public class HttpResult {
    public int code;
    public String msg;
    public T data;
}
  public class HttpResultFunc implements Function, T> {
        @Override
        public T apply(HttpResult httpResult) throws Exception {
            if (httpResult.code != HTTP_SUCCESS) {
                throw new ApiException(httpResult.code, httpResult.msg);
            }
            if (httpResult.data == null) {
                httpResult.data = (T) "";
            }
            return httpResult.data;
        }
    }
  @FormUrlEncoded
    @POST(TU_UPDATEUSER)
    Flowable> updateUser(@Field("token") String token, @Field("content") String content, @Field("type") String type);

//关键代码 返回数据处理

 String json = GsonUtil.GsonString(o);
                UserBean userRegisterBean = GsonUtil.GsonToBean(json,UserBean.class);
                UserInfoBean.getInstance().setAccess(userRegisterBean);

 

你可能感兴趣的:(android)