use of com.fasterxml.jackson.databind.module.SimpleModule in project graphhopper by graphhopper.
the class GraphHopperServletModule method createObjectMapper.
@Provides
@Singleton
ObjectMapper createObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setDateFormat(new ISO8601DateFormat());
objectMapper.registerModule(new JtsModule());
SimpleModule pathDetailModule = new SimpleModule();
pathDetailModule.addSerializer(PathDetail.class, new PathDetailSerializer());
pathDetailModule.addDeserializer(PathDetail.class, new PathDetailDeserializer());
objectMapper.registerModule(pathDetailModule);
// Because VirtualEdgeIteratorState has getters which throw Exceptions.
// http://stackoverflow.com/questions/35359430/how-to-make-jackson-ignore-properties-if-the-getters-throw-exceptions
objectMapper.registerModule(new SimpleModule().setSerializerModifier(new BeanSerializerModifier() {
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) {
return beanProperties.stream().map(bpw -> new BeanPropertyWriter(bpw) {
@Override
public void serializeAsField(Object bean, JsonGenerator gen, SerializerProvider prov) throws Exception {
try {
super.serializeAsField(bean, gen, prov);
} catch (Exception e) {
// Ignoring expected exception, see above.
}
}
}).collect(Collectors.toList());
}
}));
return objectMapper;
}
use of com.fasterxml.jackson.databind.module.SimpleModule in project druid by druid-io.
the class LoadSpecTest method setUp.
@BeforeClass
public static void setUp() {
final Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(new Module() {
@Override
public void configure(Binder binder) {
binder.bind(LocalDataSegmentPuller.class);
}
}));
mapper = new DefaultObjectMapper();
mapper.registerModule(new SimpleModule("loadSpecTest").registerSubtypes(LocalLoadSpec.class));
mapper.setInjectableValues(new GuiceInjectableValues(injector));
final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
mapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, mapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, mapper.getDeserializationConfig().getAnnotationIntrospector()));
}
use of com.fasterxml.jackson.databind.module.SimpleModule in project deeplearning4j by deeplearning4j.
the class TestSerialization method getMapper.
public ObjectMapper getMapper() {
ObjectMapper mapper = new ObjectMapper();
SimpleModule nd4j = new SimpleModule("nd4j");
nd4j.addDeserializer(INDArray.class, new NDArrayDeSerializer());
nd4j.addSerializer(INDArray.class, new NDArraySerializer());
mapper.registerModule(nd4j);
return mapper;
}
use of com.fasterxml.jackson.databind.module.SimpleModule in project druid by druid-io.
the class IngestSegmentFirehoseFactoryTest method setupInjectablesInObjectMapper.
public static ObjectMapper setupInjectablesInObjectMapper(ObjectMapper objectMapper) {
objectMapper.registerModule(new SimpleModule("testModule").registerSubtypes(LocalLoadSpec.class));
final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
objectMapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, objectMapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, objectMapper.getDeserializationConfig().getAnnotationIntrospector()));
objectMapper.setInjectableValues(new GuiceInjectableValues(GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(new Module() {
@Override
public void configure(Binder binder) {
binder.bind(LocalDataSegmentPuller.class);
}
}))));
return objectMapper;
}
use of com.fasterxml.jackson.databind.module.SimpleModule in project Gaffer by gchq.
the class JSONSerialiser method getCloseableIterableDeserialiserModule.
private static SimpleModule getCloseableIterableDeserialiserModule() {
SimpleModule module = new SimpleModule();
module.addDeserializer(CloseableIterable.class, new CloseableIterableDeserializer());
return module;
}
Aggregations