为了代码通用,你的定义对象可能是一个泛型对象,其中可变的data属性的类型参数化。那么这个泛型类型的对象,反json化时应该注意些什么呢?
-
Response类型
public static class Response<T> { private String msg; private String code; private T data; public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public T getData() { return data; } public void setData(T data) { this.data = data; } @Override public String toString() { return "Response{" + "msg='" + msg + '\'' + ", code='" + code + '\'' + ", data=" + data + '}'; } } //额外的pojo类 public static class User { private String name; private String id; public User() { } public