本文整理了Java中leap.lang.json.JSON.decodeArray()
方法的一些代码示例,展示了JSON.decodeArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSON.decodeArray()
方法的具体详情如下:
包路径:leap.lang.json.JSON
类名称:JSON
方法名:decodeArray
[英]Parse the json string and returns the the array.
[中]解析json字符串并返回数组的值。
代码示例来源:origin: org.leapframework/leap-lang
/**
* Parse the json string and converts the raw value to the target type
* @since 0.5.0b
*/
public static <T> List<T> decodeList(String json, Class<? extends T> valueType){
T[] obj = decodeArray(json,valueType);
return New.arrayList(obj);
}
代码示例来源:origin: org.leapframework/leap-webunit
/**
* Parse the response content as json and decodes to array.
*/
default <T> T[] decodeJsonArray(Class<T> componentType) {
return JSON.decodeArray(getContent(), componentType);
}
代码示例来源:origin: org.leapframework/leap-webapi
Type[] actualTypes = pType.getActualTypeArguments();
if (rawType.isAssignableFrom(List.class)) {
Object[] arr = JSON.decodeArray(jsonStr, (Class<?>) actualTypes[0]);
T val = (T) Arrays.stream(arr).collect(Collectors.toList());
return val;
代码示例来源:origin: org.leapframework/leap-db
protected GenericDbDriver[] loadDrivers() {
String configFile = this.getClass().getSimpleName() + ".driver.json";
Resource r = Resources.getResource(this.getClass(),configFile);
if(!r.exists()){
return EMPTY_DRIVES;
}
try {
String keyPrefix = I18N.getLocalizedKeyPrefix(this) + ".drivers";
try(Reader reader = r.getInputStreamReader()){
GenericDbDriver[] drivers = JSON.decodeArray(reader, GenericDbDriver.class);
for(GenericDbDriver driver : drivers){
I18N.localize(messageSource, driver, keyPrefix + "." + driver.getName());
}
return drivers;
}
} catch (IOException e) {
throw new NestedIOException("Error reading driver config file '" + r.getDescription() + "', " + e.getMessage(), e);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!