Example usage for com.fasterxml.jackson.dataformat.yaml YAMLMapper readValue

List of usage examples for com.fasterxml.jackson.dataformat.yaml YAMLMapper readValue

Introduction

In this page you can find the example usage for com.fasterxml.jackson.dataformat.yaml YAMLMapper readValue.

Prototype

@Override
@SuppressWarnings("unchecked")
public <T> T readValue(JsonParser jp, Class<T> valueType)
        throws IOException, JsonParseException, JsonMappingException 

Source Link

Document

Method to deserialize JSON content into a non-container type (it can be an array type, however): typically a bean, array or a wrapper type (like java.lang.Boolean ).

Usage

From source file:com.predic8.membrane.core.interceptor.apimanagement.ApiManagementConfiguration.java

private void parseAndConstructConfiguration(InputStream is) throws IOException {
    String yamlSource = null;/*from  ww  w . ja v  a  2 s  .  c om*/
    try {
        yamlSource = IOUtils.toString(is);
    } catch (IOException e) {
        log.warn("Could not read stream");
        return;
    }
    YAMLMapper mapper = new YAMLMapper();
    Map<String, Object> yaml = null;
    try {

        yaml = mapper.readValue(yamlSource, Map.class);
    } catch (IOException e) {
        log.warn("Could not parse yaml");
        return;
    }
    setPolicies(parsePolicies(yaml));
    setKeys(parsePoliciesForKeys(yaml));
    is.close();
    setUnauthorizedKey();
    log.info("Configuration loaded. Notifying observers");
    notifyConfigChangeObservers();
}