分享好友模块

This commit is contained in:
2024-11-06 16:36:15 +08:00
parent 090e5d320e
commit b6d3701806
6 changed files with 236 additions and 0 deletions

View File

@@ -88,6 +88,18 @@ public class JSONUtil {
}
}
public static <T> List<T> parseJSONStrTList(String jsonStr, Class<T> clazz) {
ObjectMapper objectMapper = new ObjectMapper();
try {
// 将JSON字符串转换为List<T>
return objectMapper.readValue(jsonStr, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* @param list 某集合
* @param clazz 要转成的实体