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:flink.FlowSchema.java

public FlowSchema() {
    this.mapper = new ObjectMapper();
}

From source file:myStuff.rest.app.MyObjectMapper.java

private static ObjectMapper createCombinedObjectMapper() {
    return new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true)
            .setAnnotationIntrospector(createJaxbJacksonAnnotationIntrospector());
}

From source file:com.dgtlrepublic.model.test.DataTest.java

@Test
public void validateParsingResults() throws Exception {
    List<Map> testCases = new ObjectMapper().readValue(
            new File(DataTest.class.getResource("/test-cases.json").getPath()), new TypeReference<List<Map>>() {
            });//from  w  ww.  jav  a  2  s.  c  o m
    System.out.println(String.format("Loaded %s test cases.", testCases.size()));
    long start = System.nanoTime();
    for (Map testCase : testCases) {
        verify(testCase);
    }
    System.out.println(
            String.format("Tests took: %s(ms)", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start)));
}

From source file:com.metamx.emitter.core.LoggingEmitterConfigTest.java

@Test
public void testDefaults() {
    final Properties props = new Properties();
    final ObjectMapper objectMapper = new ObjectMapper();
    final LoggingEmitterConfig config = objectMapper.convertValue(Emitters.makeLoggingMap(props),
            LoggingEmitterConfig.class);

    Assert.assertEquals(LoggingEmitter.class.getName(), config.getLoggerClass());
    Assert.assertEquals("debug", config.getLogLevel());
}

From source file:org.hibernate.ogm.datastore.redis.impl.json.JsonSerializationStrategy.java

public JsonSerializationStrategy() {
    this.objectMapper = new ObjectMapper().configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
}

From source file:nl.xillio.gitbreakers.procrastimaster.client.services.ObjectMapperService.java

public ObjectMapperService() {
    mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
}

From source file:com.fpmislata.banco.presentation.Json.Impl.JsonTransformerImplJackson.java

@Override
public <T> T fromJsonToObject(String json, Class<T> clazz) {

    try {//from  w ww .j  a  v  a  2  s . c  o m
        ObjectMapper objectMapper = new ObjectMapper();

        return objectMapper.readValue(json, clazz);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:com.orange.clara.cloud.truststore.TrustStoreStorePropertyJsonReader.java

@Override
public TrustStoreProperty read(String json) {
    try {/*from w  ww  . j  a  v  a 2  s . com*/
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(json, TrustStoreProperty.class);

    } catch (Exception e) {
        String message = String.format("Invalid truststore property.");
        throw new IllegalStateException(message, e);
    }

}

From source file:com.yahoo.elide.jsonapi.JsonApiMapper.java

/**
 * Instantiates a new JSON API OBJECT_MAPPER.
 *
 * @param dictionary the dictionary//from  w  w  w .java2  s .  c  o m
 */
public JsonApiMapper(EntityDictionary dictionary) {
    mapper = new ObjectMapper();
    mapper.registerModule(JsonApiSerializer.getModule(dictionary));
}

From source file:org.tynamo.resteasy.modules.SwaggerModule.java

@Contribute(javax.ws.rs.core.Application.class)
public static void jacksonJsonProviderSetup(Configuration<Object> singletons) {

    final ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
    /**/*from   w  w  w  . ja v  a2 s. c o m*/
     * "publishedDate": 1384267338786,
     * vs
     * "publishedDate": "2013-11-12T14:42:18.786+0000",
     */
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    JacksonJaxbJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider();
    jacksonJsonProvider.setMapper(mapper);

    singletons.add(jacksonJsonProvider);
}