十年燈 2018-04-13 09:01 采纳率: 28.6%
浏览 2578
已采纳

retrofit请求获取返回值错误

retrofit请求获取返回值的时候retrofit.RetrofitError: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 37 path $.data

 进行请求的
((App) getApplication()).getApi().updateAuthorization(access_token, nonce, timestamp, userCode, sign, userPhone, type, approvalinfo, modelIds, new Callback<AuthorityListEntity>() {
                @Override
                public void success(AuthorityListEntity authorityListEntity, Response response) {
                    if (authorityListEntity.getMessage() != null) {
                        if (authorityListEntity.isSuccess()) {
                            failed(getResources().getString(R.string.authorizesucces));
                        } else {
                            String message = authorityListEntity.getMessage();
                            if ("超时了".equals(message)) {
                                String nonce = NetWorkUtil.getNonce();
                                String timestamp = NetWorkUtil.getTimestamp();
                                String refreshToken = SharedPreferencesUtils.getString(context, Constants.REFRESHTOKEN, "");
                                String code = SharedPreferencesUtils.getString(context, Constants.USERCODE, "");
                                String sign = new Md5().getMD5ofStr("refreshToken" + "=" + refreshToken + "&" + "userCode" + "=" + code + Constants.SIGNMANTISSA).toLowerCase();
                                refresh_1(nonce, timestamp, sign, refreshToken, code);
                            } else {
                                if (!TextUtils.isEmpty(message)) {
                                    failed(MessageUtils.setMessage(context, message));
                                }
                            }
                        }

返回值

 {"accountOperationType":"2","data":{},"message":"编辑授权成功","modelIds":null,"page":0,"success":true,"total":0,"totalPages":0}

下面是bean

public class AuthorityListEntity {

    private String message;
    private int page;
    private boolean success;
    private int total;
    private String accountOperationType;
    private List<String> modelIds;
    private List<DataBean> data;
    private int totalPages;

    public List<String> getModelIds() {
        return modelIds;
    }

    public void setModelIds(List<String> modelIds) {
        this.modelIds = modelIds;
    }

    public String getAccountOperationType() {
        return accountOperationType;
    }

    public void setAccountOperationType(String accountOperationType) {
        this.accountOperationType = accountOperationType;
    }


    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public class DataBean {
        private String userPhone;
        private String deviceAddress;
        private int deviceNum;
        private String name;
        private String icon;
        private String isAuthorited;
        private String roomCode;
        private String deviceCode;
        private String type;
        private String userCode;
        private String accountOperationType;
        private String validationCode;

        public String getAccountOperationType() {
            return accountOperationType;
        }

        public void setAccountOperationType(String accountOperationType) {
            this.accountOperationType = accountOperationType;
        }

        public String getValidationCode() {
            return validationCode;
        }

        public void setValidationCode(String validationCode) {
            this.validationCode = validationCode;
        }

        public String getUserPhone() {
            return userPhone;
        }

        public void setUserPhone(String userPhone) {
            this.userPhone = userPhone;
        }

        public String getDeviceAddress() {
            return deviceAddress;
        }

        public void setDeviceAddress(String deviceAddress) {
            this.deviceAddress = deviceAddress;
        }

        public int getDeviceNum() {
            return deviceNum;
        }

        public void setDeviceNum(int deviceNum) {
            this.deviceNum = deviceNum;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getIcon() {
            return icon;
        }

        public void setIcon(String icon) {
            this.icon = icon;
        }

        public String getIsAuthorited() {
            return isAuthorited;
        }

        public void setIsAuthorited(String isAuthorited) {
            this.isAuthorited = isAuthorited;
        }

        public String getRoomCode() {
            return roomCode;
        }

        public void setRoomCode(String roomCode) {
            this.roomCode = roomCode;
        }

        public String getDeviceCode() {
            return deviceCode;
        }

        public void setDeviceCode(String deviceCode) {
            this.deviceCode = deviceCode;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getUserCode() {
            return userCode;
        }

        public void setUserCode(String userCode) {
            this.userCode = userCode;
        }
    }
}

  • 写回答

4条回答

  • Sloth-er 2018-04-13 09:32
    关注

    {"accountOperationType":"2"**,"data":{},**"message":"编辑授权成功","modelIds":null,"page":0,"success":true,"total":0,"totalPages":0}

    data域的返回值错误,{}应该改成【】

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办