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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations