Search in sources :

Example 1 with TypeReference

use of org.nd4j.shade.jackson.core.type.TypeReference in project deeplearning4j by deeplearning4j.

the class KerasModel method parseYamlString.

/**
     * Convenience function for parsing JSON strings.
     *
     * @param json    String containing valid JSON
     * @return        Nested (key,value) map of arbitrary depth
     * @throws IOException
     */
public static Map<String, Object> parseYamlString(String json) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
    };
    return mapper.readValue(json, typeRef);
}
Also used : YAMLFactory(org.nd4j.shade.jackson.dataformat.yaml.YAMLFactory) TypeReference(org.nd4j.shade.jackson.core.type.TypeReference) ObjectMapper(org.nd4j.shade.jackson.databind.ObjectMapper)

Example 2 with TypeReference

use of org.nd4j.shade.jackson.core.type.TypeReference in project deeplearning4j by deeplearning4j.

the class KerasModel method parseJsonString.

/**
     * Convenience function for parsing JSON strings.
     *
     * @param json    String containing valid JSON
     * @return        Nested (key,value) map of arbitrary depth
     * @throws IOException
     */
public static Map<String, Object> parseJsonString(String json) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
    };
    return mapper.readValue(json, typeRef);
}
Also used : TypeReference(org.nd4j.shade.jackson.core.type.TypeReference) ObjectMapper(org.nd4j.shade.jackson.databind.ObjectMapper)

Aggregations

TypeReference (org.nd4j.shade.jackson.core.type.TypeReference)2 ObjectMapper (org.nd4j.shade.jackson.databind.ObjectMapper)2 YAMLFactory (org.nd4j.shade.jackson.dataformat.yaml.YAMLFactory)1