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:com.chiralbehaviors.scout.server.ScoutConfiguration.java

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

From source file:com.github.lburgazzoli.hazelcast.serialization.json.JsonEnvelope.java

public static <T> T asObject(JsonEnvelope envelope, ObjectMapper mapper, Class<T> type) throws IOException {
    return mapper.readValue(envelope.data, type);
}

From source file:com.shampan.db.collections.fragment.photo.Image.java

public static Image getImageInfo(String jsonContent) {
    Image imageInfo = null;//from  w w  w . j  av a 2  s.  c o m
    try {
        ObjectMapper mapper = new ObjectMapper();
        imageInfo = mapper.readValue(jsonContent, Image.class);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return imageInfo;
}

From source file:com.shampan.db.collections.fragment.status.ReferenceList.java

public static ReferenceList getReferenceList(String jsonContent) {
    ReferenceList refList = null;/*from w ww  . j  a v a2s . c  o  m*/
    try {
        ObjectMapper mapper = new ObjectMapper();
        refList = mapper.readValue(jsonContent, ReferenceList.class);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return refList;
}

From source file:com.huangyunkun.jviff.config.ConfigManager.java

public static Config getConfigFromFile(String filePath) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    Config config = mapper.readValue(new File(filePath), Config.class);
    if (StringUtils.isEmpty(config.getOutputDir())) {
        config.setOutputDir(Files.createTempDir().getAbsolutePath());
    }//from  w ww .  j a va2 s.c  o  m
    return config;
}

From source file:com.shampan.db.collections.fragment.status.Like.java

public static Like getStatusLike(String jsonContent) {
    Like likeInfo = null;//from ww w . j  a v a  2s . co  m
    try {
        ObjectMapper mapper = new ObjectMapper();
        likeInfo = mapper.readValue(jsonContent, Like.class);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return likeInfo;
}

From source file:dk.dma.msiproxy.common.util.JsonUtils.java

/**
 * Parses the json data as an entity of the given class
 *
 * @param data the json data to parse/*from w  w w .j  a  v a 2  s  .  c  o  m*/
 * @param dataClass the class of the data
 * @return the parsed data
 */
public static <T> T fromJson(String data, Class<T> dataClass) throws IOException {
    ObjectMapper jsonMapper = new ObjectMapper();
    return jsonMapper.readValue(data, dataClass);
}

From source file:dk.dma.msiproxy.common.util.JsonUtils.java

/**
 * Parses the json data as an entity of the given class
 *
 * @param in the json data to parse/*from w  ww .j  a  va2 s .  c o  m*/
 * @param dataClass the class of the data
 * @return the parsed data
 */
public static <T> T fromJson(InputStream in, Class<T> dataClass) throws IOException {
    ObjectMapper jsonMapper = new ObjectMapper();
    return jsonMapper.readValue(in, dataClass);
}

From source file:AIR.Common.Json.JsonHelper.java

public static <T> T deserialize(String json, TypeReference<T> typeReference)
        throws JsonParseException, JsonMappingException, IOException {
    if (StringUtils.isEmpty(json))
        return null;

    ObjectMapper mapper = new ObjectMapper();

    return mapper.readValue(json, typeReference);
}

From source file:org.trustedanalytics.user.common.UaaProblemReader.java

public static UaaProblem read(HttpStatusCodeException e) {
    ObjectMapper objectMapper = new ObjectMapper();
    try {/*from w  w w.j  a  va  2 s.  c  o  m*/
        return objectMapper.readValue(e.getResponseBodyAsString(), UaaProblem.class);
    } catch (IOException e1) {
        LOGGER.error(e1);
        return null;
    }
}