mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method
This commit is contained in:
@@ -9,6 +9,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@@ -113,6 +114,21 @@ public interface JSONGetter<K> extends OptNullBasicTypeFromObjectGetter<K> {
|
||||
return (null == obj) ? null : obj.toBean(beanType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从JSON中直接获取Bean的List列表<br>
|
||||
* 先获取JSONArray对象,然后转为Bean的List
|
||||
*
|
||||
* @param <T> Bean类型
|
||||
* @param key KEY
|
||||
* @param beanType Bean类型
|
||||
* @return Bean的List,如果值为null或者非JSONObject类型,返回null
|
||||
* @since 5.7.20
|
||||
*/
|
||||
default <T> List<T> getBeanList(K key, Class<T> beanType) {
|
||||
final JSONArray jsonArray = getJSONArray(key);
|
||||
return (null == jsonArray) ? null : jsonArray.toList(beanType);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Date getDate(K key, Date defaultValue) {
|
||||
// 默认转换
|
||||
|
Reference in New Issue
Block a user