原文链接:https://muyig.github.io/blog/2020/01/10/TypeReference/
String userString = "[{\"userId\":\"111\",\"userName\":\"Tom\"},{\"userId\":\"222\",\"userName\":\"Jerry\"}]";
List<UserInfo> input = new ArrayList<>();
List<UserInfo> userInfoList = JSON.parseObject(userString, input.getClass());
java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to com.vdian.dagon.core.user.UserInfo
List<UserInfo> userInfoList = JSON.parseObject(userString, new TypeReference<List<UserInfo>>() {
});
@SuppressWarnings("unchecked")
public static <T> T parseObject(String text, TypeReference<T> type, Feature... features) {
return (T) parseObject(text, type.type, ParserConfig.global, DEFAULT_PARSER_FEATURE, features);
}
new Runnable() {
@Override
public void