Search in sources :

Example 1 with StreamSerializer

use of com.fasterxml.jackson.datatype.jdk8.StreamSerializer in project keycloak by keycloak.

the class ObjectMapperResolver method createStreamSerializer.

public static ObjectMapper createStreamSerializer() {
    ObjectMapper mapper = new ObjectMapper();
    JavaType type = TypeFactory.unknownType();
    JavaType streamType = mapper.getTypeFactory().constructParametricType(Stream.class, type);
    SimpleModule module = new SimpleModule();
    module.addSerializer(new StreamSerializer(streamType, type));
    mapper.registerModule(module);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    if (Boolean.parseBoolean(System.getProperty("keycloak.jsonPrettyPrint", "false"))) {
        mapper.enable(SerializationFeature.INDENT_OUTPUT);
    }
    return mapper;
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) StreamSerializer(com.fasterxml.jackson.datatype.jdk8.StreamSerializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule)

Aggregations

JavaType (com.fasterxml.jackson.databind.JavaType)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 StreamSerializer (com.fasterxml.jackson.datatype.jdk8.StreamSerializer)1