Search in sources :

Example 6 with Jdk8Module

use of com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project dropwizard by dropwizard.

the class Jackson method configure.

private static ObjectMapper configure(ObjectMapper mapper) {
    mapper.registerModule(new GuavaModule());
    mapper.registerModule(new LogbackModule());
    mapper.registerModule(new GuavaExtrasModule());
    mapper.registerModule(new JodaModule());
    mapper.registerModule(new AfterburnerModule());
    mapper.registerModule(new FuzzyEnumModule());
    mapper.registerModule(new ParameterNamesModule());
    mapper.registerModules(new Jdk8Module());
    mapper.registerModules(new JavaTimeModule());
    mapper.setPropertyNamingStrategy(new AnnotationSensitivePropertyNamingStrategy());
    mapper.setSubtypeResolver(new DiscoverableSubtypeResolver());
    return mapper;
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) ParameterNamesModule(com.fasterxml.jackson.module.paramnames.ParameterNamesModule) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule)

Example 7 with Jdk8Module

use of com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project buck by facebook.

the class ObjectMappers method newDefaultInstance.

public static ObjectMapper newDefaultInstance() {
    ObjectMapper mapper = new ObjectMapper();
    // Disable automatic flush() after mapper.write() call, because it is usually unnecessary,
    // and it makes BufferedOutputStreams to be useless
    mapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
    // Add support for serializing Guava collections.
    mapper.registerModule(new GuavaModule());
    mapper.registerModule(new Jdk8Module());
    return mapper;
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule)

Example 8 with Jdk8Module

use of com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project keywhiz by square.

the class JsonHelpers method customizeObjectMapper.

/**
   * Customized ObjectMapper for common settings.
   *
   * @return customized object mapper
   */
private static ObjectMapper customizeObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new Jdk8Module());
    mapper.registerModule(new GuavaModule());
    mapper.registerModule(new LogbackModule());
    mapper.registerModule(new GuavaExtrasModule());
    mapper.registerModule(new FuzzyEnumModule());
    mapper.setPropertyNamingStrategy(new AnnotationSensitivePropertyNamingStrategy());
    mapper.setSubtypeResolver(new DiscoverableSubtypeResolver());
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper;
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) GuavaExtrasModule(io.dropwizard.jackson.GuavaExtrasModule) FuzzyEnumModule(io.dropwizard.jackson.FuzzyEnumModule) DiscoverableSubtypeResolver(io.dropwizard.jackson.DiscoverableSubtypeResolver) LogbackModule(io.dropwizard.jackson.LogbackModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule) AnnotationSensitivePropertyNamingStrategy(io.dropwizard.jackson.AnnotationSensitivePropertyNamingStrategy)

Example 9 with Jdk8Module

use of com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method getMapperStepAction.

public Action getMapperStepAction(ConnectorDescriptor outputConnectorDescriptor) {
    ObjectMapper mapper = new ObjectMapper().registerModules(new Jdk8Module());
    Action ts = new StepAction.Builder().descriptor(new StepDescriptor.Builder().build()).build();
    try {
        DataShape inputDataShape = new DataShape.Builder().kind(DataShapeKinds.ANY).name("All preceding outputs").build();
        JSONObject json = new JSONObject(mapper.writeValueAsString(ts));
        JSONObject inputDataType = new JSONObject(mapper.writeValueAsString(inputDataShape));
        JSONObject outputDataType = new JSONObject(mapper.writeValueAsString(outputConnectorDescriptor.getInputDataShape().get()));
        json.getJSONObject("descriptor").put("inputDataShape", inputDataType);
        json.getJSONObject("descriptor").put("outputDataShape", outputDataType);
        ts = Json.reader().forType(Action.class).readValue(json.toString());
        log.debug(mapper.writeValueAsString(ts));
    } catch (IOException ex) {
        log.error("Error: " + ex);
    }
    return ts;
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) Action(io.syndesis.common.model.action.Action) StepAction(io.syndesis.common.model.action.StepAction) JSONObject(org.json.JSONObject) StepDescriptor(io.syndesis.common.model.action.StepDescriptor) IOException(java.io.IOException) DataShape(io.syndesis.common.model.DataShape) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 10 with Jdk8Module

use of com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project syndesis-qe by syndesisio.

the class AbstractEndpoint method list.

public List<T> list(String id) {
    final ObjectMapper mapper = new ObjectMapper().registerModules(new Jdk8Module());
    mapper.configure(Feature.AUTO_CLOSE_SOURCE, true);
    final ObjectWriter ow = mapper.writer();
    final Class<ListResult<T>> listtype = (Class) ListResult.class;
    log.debug("GET : {}", getEndpointUrl(Optional.ofNullable(id)));
    final Invocation.Builder invocation = this.createInvocation(id);
    final JsonNode response = invocation.get(JsonNode.class);
    ListResult<T> result = null;
    try {
        result = Json.reader().forType(listtype).readValue(response.toString());
    } catch (IOException ex) {
        log.error("" + ex);
    }
    final List<T> ts = new ArrayList<>();
    for (int i = 0; i < result.getTotalCount(); i++) {
        T con = null;
        try {
            final String json = ow.writeValueAsString(result.getItems().get(i));
            con = Json.reader().forType(type).readValue(json);
        } catch (IOException ex) {
            log.error(ex.toString());
        }
        ts.add(con);
    }
    return ts;
}
Also used : Invocation(javax.ws.rs.client.Invocation) ArrayList(java.util.ArrayList) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ListResult(io.syndesis.common.model.ListResult) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)5 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)4 IOException (java.io.IOException)3 ParameterNamesModule (com.fasterxml.jackson.module.paramnames.ParameterNamesModule)2 Action (io.syndesis.common.model.action.Action)2 JSONObject (org.json.JSONObject)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)1 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)1 Provides (com.google.inject.Provides)1 AnnotationSensitivePropertyNamingStrategy (io.dropwizard.jackson.AnnotationSensitivePropertyNamingStrategy)1 DiscoverableSubtypeResolver (io.dropwizard.jackson.DiscoverableSubtypeResolver)1 FuzzyEnumModule (io.dropwizard.jackson.FuzzyEnumModule)1 GuavaExtrasModule (io.dropwizard.jackson.GuavaExtrasModule)1 LogbackModule (io.dropwizard.jackson.LogbackModule)1