K - Key类型public interface JSONGetter<K> extends TypeGetter<K>
| 限定符和类型 | 方法和说明 |
|---|---|
JSONConfig |
config()
获取JSON配置
|
default <T> T |
get(K key,
Type type,
T defaultValue) |
default <T> T |
getBean(K key,
Class<T> beanType)
从JSON中直接获取Bean对象
先获取JSONObject对象,然后转为Bean对象 |
default <T> List<T> |
getBeanList(K key,
Class<T> beanType)
从JSON中直接获取Bean的List列表
先获取JSONArray对象,然后转为Bean的List |
default JSONArray |
getJSONArray(K key)
获得JSONArray对象
如果值为其它类型对象,尝试转换为 JSONArray返回,否则抛出异常 |
default JSONObject |
getJSONObject(K key)
获得JSONObject对象
如果值为其它类型对象,尝试转换为 JSONObject返回,否则抛出异常 |
default String |
getStrEscaped(K key)
获取字符串类型值,并转义不可见字符,如'\n'换行符会被转义为字符串"\n"
|
default String |
getStrEscaped(K key,
String defaultValue)
获取字符串类型值,并转义不可见字符,如'\n'换行符会被转义为字符串"\n"
|
default boolean |
isNull(K key)
key对应值是否为
null或无此key |
get, get, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBool, getBool, getByte, getByte, getBytes, getBytes, getChar, getChar, getDate, getDate, getDouble, getDouble, getEnum, getEnum, getFloat, getFloat, getInt, getInt, getLocalDate, getLocalDate, getLocalDateTime, getLocalDateTime, getLocalTime, getLocalTime, getLong, getLong, getNumber, getNumber, getObj, getObj, getShort, getShort, getSqlTime, getSqlTime, getSqlTimestamp, getSqlTimestamp, getStr, getStrJSONConfig config()
JSONConfigdefault boolean isNull(K key)
null或无此keykey - 键null返回false,其它返回truedefault String getStrEscaped(K key)
key - 键default String getStrEscaped(K key, String defaultValue)
key - 键defaultValue - 默认值default JSONArray getJSONArray(K key)
JSONArray返回,否则抛出异常key - KEYnull,返回null,非JSONArray类型,尝试转换,转换失败抛出异常default JSONObject getJSONObject(K key)
JSONObject返回,否则抛出异常key - KEYnull,返回null,非JSONObject类型,尝试转换,转换失败抛出异常default <T> T getBean(K key, Class<T> beanType)
T - Bean类型key - KEYbeanType - Bean类型default <T> List<T> getBeanList(K key, Class<T> beanType)
T - Bean类型key - KEYbeanType - Bean类型default <T> T get(K key, Type type, T defaultValue)
get 在接口中 TypeGetter<K>Copyright © 2023. All rights reserved.