- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.readValue()
方法的一些代码示例,展示了YAMLMapper.readValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAMLMapper.readValue()
方法的具体详情如下:
包路径:com.fasterxml.jackson.dataformat.yaml.YAMLMapper
类名称:YAMLMapper
方法名:readValue
暂无
代码示例来源:origin: com.github.duanxinyuan/library-json-jackson
/**
* 反序列化Yaml文件
* @param path 文件路径
*/
public static <V> V fromYamlFile(String path, Class<V> c) {
try {
return yamlMapper.readValue(new File(path), c);
} catch (IOException e) {
log.error("jackson from yaml error, path: {}, type: {}", path, c, e);
return null;
}
}
代码示例来源:origin: com.github.duanxinyuan/library-json-jackson
/**
* 反序列化Yaml文件
* @param path 文件路径
*/
public static <V> V fromYamlFile(String path, TypeReference<V> type) {
try {
return yamlMapper.readValue(new File(path), type);
} catch (IOException e) {
log.error("jackson from yaml error, path: {}, type: {}", path, type, e);
return null;
}
}
代码示例来源:origin: org.seedstack.seed/seed-core
@Override
public Map<String, Object> collect() {
Map<String, Object> result = new HashMap<>();
result.put("version", seedVersion == null ? "UNKNOWN" : seedVersion);
result.put("businessVersion", businessVersion == null ? "UNKNOWN" : businessVersion);
result.put("inconsistentPlugins", inconsistentPlugins);
result.put("contextClass", context == null ? "NONE" : context.getClass().getName());
try {
result.put("configuration", yamlMapper.readValue(configuration.toString(), Map.class));
} catch (IOException | RuntimeException e) {
result.put("rawConfiguration", configuration.toString());
}
return result;
}
}
代码示例来源:origin: com.github.cafdataprocessing/worker-document-testing-unit
/**
* Configures a new Document using a file with JSON or YAML-serialized Document Worker task
*
* @param path File path
* @return current Document builder
* @throws IOException An issue with accessing a file
*/
public static DocumentBuilder fromFile(final String path) throws IOException
{
final YAMLMapper mapper = new YAMLMapper();
final byte[] bytes = FileUtils.readFileToByteArray(new File(path));
final DocumentWorkerDocumentTask workerTask = mapper.readValue(bytes, DocumentWorkerDocumentTask.class);
return new DocumentBuilder(workerTask);
}
代码示例来源:origin: com.github.duanxinyuan/library-json-jackson
/**
* 反序列化Recources目录下的Yaml文件
* @param name 文件名
*/
public static <V> V fromYamlRecource(String name, Class<V> c) {
try (InputStream inputStream = getResourceStream(name); InputStreamReader reader = getResourceReader(inputStream)) {
if (reader == null) {
return null;
}
return yamlMapper.readValue(reader, c);
} catch (IOException e) {
log.error("jackson from yaml recource error, name: {}, type: {}", name, c, e);
return null;
}
}
代码示例来源:origin: com.github.duanxinyuan/library-json-jackson
/**
* 反序列化Recources目录下的Yaml文件
* @param name 文件名
*/
public static <V> V fromYamlRecource(String name, TypeReference<V> type) {
try (InputStream inputStream = getResourceStream(name); InputStreamReader reader = getResourceReader(inputStream)) {
if (reader == null) {
return null;
}
return yamlMapper.readValue(reader, type);
} catch (IOException e) {
log.error("jackson from yaml recource error, name: {}, type: {}", name, type, e);
return null;
}
}
代码示例来源:origin: me.snowdrop/istio-common
Object deserialize(JsonNode node, String fieldName, Class targetClass, DeserializationContext ctxt) throws IOException {
final String type = getFieldClassFQN(targetClass, valueType);
try {
// load class of the field
final Class<?> fieldClass = Thread.currentThread().getContextClassLoader().loadClass(type);
// create a map type matching the type of the field from the mapping information
final YAMLMapper codec = (YAMLMapper) ctxt.getParser().getCodec();
MapType mapType = codec.getTypeFactory().constructMapType(Map.class, String.class, fieldClass);
// get a parser taking the current value as root
final JsonParser traverse = node.get(fieldName).traverse(codec);
// and use it to deserialize the subtree as the map type we just created
return codec.readValue(traverse, mapType);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Unsupported type '" + type + "' for field '" + fieldName +
"' on '" + targetClass.getName() + "' class. Full type was " + this, e);
}
}
}
代码示例来源:origin: me.snowdrop/istio-model
document = document.trim();
if (!document.isEmpty()) {
final Map<String, Object> resourceYaml = objectMapper.readValue(document, Map.class);
代码示例来源:origin: snowdrop/istio-java-api
Object deserialize(JsonNode node, String fieldName, Class targetClass, DeserializationContext ctxt) throws IOException {
final String type = getFieldClassFQN(targetClass, valueType);
try {
// load class of the field
final Class<?> fieldClass = Thread.currentThread().getContextClassLoader().loadClass(type);
// create a map type matching the type of the field from the mapping information
final YAMLMapper codec = (YAMLMapper) ctxt.getParser().getCodec();
MapType mapType = codec.getTypeFactory().constructMapType(Map.class, String.class, fieldClass);
// get a parser taking the current value as root
final JsonParser traverse = node.get(fieldName).traverse(codec);
// and use it to deserialize the subtree as the map type we just created
return codec.readValue(traverse, mapType);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Unsupported type '" + type + "' for field '" + fieldName +
"' on '" + targetClass.getName() + "' class. Full type was " + this, e);
}
}
}
代码示例来源:origin: snowdrop/istio-java-api
document = document.trim();
if (!document.isEmpty()) {
final Map<String, Object> resourceYaml = objectMapper.readValue(document, Map.class);
代码示例来源:origin: io.takari.orchestra.plugins/yaml
@Override
public Collection<ProcessDefinition> parse(InputStream in) throws ParserException {
YAMLMapper m = new YAMLMapper();
Map<String, Object> data;
try {
data = m.readValue(in, Map.class);
} catch (IOException e) {
throw new ParserException("Error while parsing the data", e);
}
log.debug("parse -> got: {}", data);
Collection<ProcessDefinition> result = new ArrayList<>();
for (Map.Entry<String, Object> entry : data.entrySet()) {
String id = entry.getKey();
Object v = entry.getValue();
if (!(v instanceof List)) {
throw new ParserException("Unsupported element type in the process '" + id + "': " + v);
}
List<Object> l = (List<Object>) v;
IdGenerator idGenerator = new IdGenerator();
ProcessDefinition pd = new ProcessDefinition(id, addEntryPoint(idGenerator, toElements(idGenerator, l)),
Collections.singletonMap(ProcessDefinition.SOURCE_TYPE_ATTRIBUTE, TYPE));
if (log.isDebugEnabled()) {
print(pd, 0);
}
result.add(pd);
}
return result;
}
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.readValue()方法的一些代码示例,展示了YAMLMapper.readVa
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.enable()方法的一些代码示例,展示了YAMLMapper.enable()的
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.convertValue()方法的一些代码示例,展示了YAMLMapper.con
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.readerFor()方法的一些代码示例,展示了YAMLMapper.reader
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.readTree()方法的一些代码示例,展示了YAMLMapper.readTre
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.disable()方法的一些代码示例,展示了YAMLMapper.disable(
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.setSerializationInclusion()方法的一些代码示例,展示了Y
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.configure()方法的一些代码示例,展示了YAMLMapper.config
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.writeValueAsString()方法的一些代码示例,展示了YAMLMapp
本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLMapper.()方法的一些代码示例,展示了YAMLMapper.()的具体用法。这些代码示例主
本文整理了Java中com.vmware.admiral.common.util.YamlMapper.fromYamlToJson()方法的一些代码示例,展示了YamlMapper.fromYaml
本文整理了Java中com.vmware.admiral.common.util.YamlMapper.objectMapper()方法的一些代码示例,展示了YamlMapper.objectMapp
本文整理了Java中com.vmware.admiral.common.util.YamlMapper.splitYaml()方法的一些代码示例,展示了YamlMapper.splitYaml()的具
本文整理了Java中com.vmware.admiral.common.util.YamlMapper.isMultiYaml()方法的一些代码示例,展示了YamlMapper.isMultiYaml
我尝试使用 Jackson YAMLMapper 反序列化和重新序列化以下 YAML 内容。但是,缺少标签 !ImportValue。请告诉我如何保留 YAML 标签 !ImportValue。 原创
我是一名优秀的程序员,十分优秀!