use of com.fasterxml.jackson.databind.ser.Serializers in project spring-framework by spring-projects.
the class Jackson2ObjectMapperBuilderTests method modulesToInstallByInstance.
@Test
public void modulesToInstallByInstance() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modulesToInstall(new CustomIntegerModule()).build();
Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
assertSame(CustomIntegerSerializer.class, serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass());
}
use of com.fasterxml.jackson.databind.ser.Serializers in project spring-framework by spring-projects.
the class Jackson2ObjectMapperBuilderTests method serializerByType.
@Test
public void serializerByType() {
JsonSerializer<Number> serializer = new NumberSerializer(Integer.class);
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modules(// Disable well-known modules detection
new ArrayList<>()).serializerByType(Boolean.class, serializer).build();
assertTrue(getSerializerFactoryConfig(objectMapper).hasSerializers());
Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
assertSame(serializer, serializers.findSerializer(null, SimpleType.construct(Boolean.class), null));
}
Aggregations