泛型反序列化成对象
实体类
@Data
public class KeyClass implements Serializable {
private T record;
private String type;
}
@Data
public class TClass {
private Long id;
}
数据转换
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
KeyClass<TClass > result = JSONObject.parseObject(resp, new TypeReference<KeyClass<TClass >>(){});
导入的包使用阿里巴巴的fastJson;