Example usage for com.fasterxml.jackson.databind ObjectMapper readValue

List of usage examples for com.fasterxml.jackson.databind ObjectMapper readValue

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind ObjectMapper readValue.

Prototype

@SuppressWarnings("unchecked")
    public <T> T readValue(byte[] src, JavaType valueType)
            throws IOException, JsonParseException, JsonMappingException 

Source Link

Usage

From source file:io.yields.math.framework.kpi.ScoreDAO.java

private static ScoreResult fromFile(Path file) {

    ObjectMapper jsonMapper = getObjectMapper();
    try {/*from  w  ww .ja v a  2  s .co m*/
        return jsonMapper.readValue(file.toFile(), ScoreResult.class);
    } catch (IOException ioe) {
        throw new RuntimeException("Error reading yields KPI file from " + file, ioe);
    }
}

From source file:com.chiralBehaviors.groo.configuration.ChakaalConfiguration.java

public static ChakaalConfiguration fromYaml(InputStream yaml)
        throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    mapper.registerModule(new DiscoveryModule());
    return mapper.readValue(yaml, ChakaalConfiguration.class);
}

From source file:com.company.et.service.JsonService.java

public static Task jsonToObjectTask(String json) throws IOException, ParseException {

    ObjectMapper mapper = new ObjectMapper();
    Task obj = mapper.readValue(json, Task.class);

    return obj;/*from ww w.j  a va2 s.c o  m*/
}

From source file:am.ik.sendgrid.util.JsonCodec.java

public static <T> Function<InputStream, T> decode(ObjectMapper objectMapper, TypeReference<T> type) {
    return inputStream -> {
        try (InputStream in = inputStream) {
            return objectMapper.readValue(in, type);
        } catch (IOException e) {
            throw new UncheckedIOException("Unable to parse JSON Payload", e);
        }//  w  w w .ja v  a2 s  . c  om
    };
}

From source file:nl.esciencecenter.xnattool.DataSetConfigList.java

public static DataSetConfigList parseXML(String xml)
        throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper xmlMapper = new XmlMapper();
    DataSetConfigList value = xmlMapper.readValue(xml, DataSetConfigList.class);
    // check ?/*from  w  w w .  j  av a2  s  .  c  o  m*/
    return value;
}

From source file:org.axway.grapes.commons.utils.JsonUtils.java

/**
 * Un-serialize a Json into Organization
 * @param organization String/*www .jav a2s .c  o  m*/
 * @return Organization
 * @throws IOException
 */
public static Organization unserializeOrganization(final String organization) throws IOException {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS);
    return mapper.readValue(organization, Organization.class);
}

From source file:org.axway.grapes.commons.utils.JsonUtils.java

/**
 * Un-serialize a Json into Module/*from w w w. j a  va  2  s .c o  m*/
 * @param module String
 * @return Module
 * @throws IOException
 */
public static Module unserializeModule(final String module) throws IOException {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS);
    return mapper.readValue(module, Module.class);
}

From source file:org.axway.grapes.commons.utils.JsonUtils.java

/**
 * Un-serialize a report with Json/*ww w . j av  a 2s . c  o  m*/
 * @param artifact String
 * @return Artifact
 * @throws IOException 
 */
public static Artifact unserializeArtifact(final String artifact) throws IOException {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS);
    return mapper.readValue(artifact, Artifact.class);
}

From source file:org.axway.grapes.commons.utils.JsonUtils.java

/**
 * Un-serialize a report with Json/*from  w  w w .  ja  va2s  . c  om*/
 * @param license String
 * @return License
 * @throws IOException 
 */
public static License unserializeLicense(final String license) throws IOException {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS);
    return mapper.readValue(license, License.class);
}

From source file:org.axway.grapes.commons.utils.JsonUtils.java

/**
 * Un-serialize a Json into BuildInfo/*from  w  ww . ja  v a  2  s .c o m*/
 * @param buildInfo String
 * @return Map<String,String>
 * @throws IOException
 */
public static Map<String, String> unserializeBuildInfo(final String buildInfo) throws IOException {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS);
    return mapper.readValue(buildInfo, new TypeReference<Map<String, Object>>() {
    });
}