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

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

Introduction

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

Prototype

public ObjectMapper() 

Source Link

Document

Default constructor, which will construct the default JsonFactory as necessary, use SerializerProvider as its SerializerProvider , and BeanSerializerFactory as its SerializerFactory .

Usage

From source file:io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaRequest.java

public static RegisterSchemaRequest fromJson(String json) throws IOException {
    return new ObjectMapper().readValue(json, RegisterSchemaRequest.class);
}

From source file:com.elearning.rest1.config.TestUtils.java

public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper.writeValueAsBytes(object);
}

From source file:it.reply.orchestrator.util.TestUtil.java

/**
 * Convert Object To a Json byte array.//from www . j  a va2 s. c  o  m
 * 
 * @return byte[]
 */
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper.writeValueAsBytes(object);
}

From source file:com.mattermost.service.jacksonconverter.JacksonConverterFactory.java

public static JacksonConverterFactory create() {
    return create(new ObjectMapper());
}

From source file:milo.jersey.JsonConfiguration.java

private static ObjectMapper createDefaultMapper() {
    ObjectMapper result = new ObjectMapper();

    result.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    return result;
}

From source file:io.fabric8.maven.core.util.JSONUtil.java

public static boolean equals(JSONObject first, JSONObject second) {
    final ObjectMapper mapper = new ObjectMapper();

    try {//  w  w  w .j  av a2s.  c  om
        final JsonNode tree1 = mapper.readTree(first.toString());
        final JsonNode tree2 = mapper.readTree(second.toString());
        return tree1.equals(tree2);
    } catch (IOException e) {
        return false;
    }
}

From source file:org.hawkular.client.test.utils.JSONHelper.java

public static <T> T load(Class<T> clz, File jsonFile) {
    ObjectMapper mapper = new ObjectMapper();

    try {//  w ww .  j a  v  a 2  s  .com
        return mapper.readValue(jsonFile, clz);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.baswell.routes.JacksonBridge.java

static <RequestContentType extends Object> RequestContentType parseJackson(byte[] contentBytes,
        Type contentType) throws IOException {
    return (RequestContentType) new ObjectMapper().readValue(contentBytes,
            TypeFactory.defaultInstance().constructType(contentType));
}

From source file:gaffer.function.ConsumerFunctionTest.java

private static ObjectMapper createObjectMapper() {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
    return mapper;
}

From source file:com.mac.holdempoker.socket.JsonConverter.java

public static Object fromJsonString(String json, Class<? extends Object> type) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper();

    //convert json string to object
    Object obj = objectMapper.readValue(json, type);
    return type.cast(obj);
}