BasicResponse<T>遇到如下问题该如何解决呢
Closed this issue · 1 comments
fail572872916 commented
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 68 path $.result
当后台返回一个数组时直接炸了
这是我改造后的
`public class BasicResponse {
private int code;
private String message;
private T result;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getResult() {
return result;
}
public void setResult(T result) {
this.result = result;
}
public boolean isSuccess(){
return getCode()== 10000;
}
public T getInfo() {
return info;
}
public void setInfo(T info) {
this.info = info;
}
private T info;
}
`
这是后台返回的
{"code":10001,"message":"\u9a8c\u8bc1\u7801\u9519\u8bef","result":[]}
fail572872916 commented
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 68 path $.result
当后台返回一个数组时直接炸了这是我改造后的
`public class BasicResponse {private int code; private String message; private T result; public int getCode() { return code; } public void setCode(int code) { this.code = code; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public T getResult() { return result; } public void setResult(T result) { this.result = result; } public boolean isSuccess(){ return getCode()== 10000; } public T getInfo() { return info; } public void setInfo(T info) { this.info = info; } private T info;
}
`这是后台返回的
{"code":10001,"message":"\u9a8c\u8bc1\u7801\u9519\u8bef","result":[]}
原因找到了, 是后台返回不会规范的问题