Search in sources :

Example 1 with ToStringSerializer

use of com.fasterxml.jackson.databind.ser.std.ToStringSerializer in project oc-explorer by devgateway.

the class MvcConfig method objectMapperBuilder.

@Bean
public Jackson2ObjectMapperBuilder objectMapperBuilder() {
    Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
    // builder.featuresToEnable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
    SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
    builder.serializationInclusion(Include.NON_EMPTY).dateFormat(dateFormatGmt);
    builder.serializerByType(GeoJsonPoint.class, new GeoJsonPointSerializer());
    builder.serializerByType(ObjectId.class, new ToStringSerializer());
    builder.defaultViewInclusion(true);
    return builder;
}
Also used : Jackson2ObjectMapperBuilder(org.springframework.http.converter.json.Jackson2ObjectMapperBuilder) ToStringSerializer(com.fasterxml.jackson.databind.ser.std.ToStringSerializer) GeoJsonPointSerializer(org.devgateway.ocds.web.rest.serializers.GeoJsonPointSerializer) SimpleDateFormat(java.text.SimpleDateFormat) Bean(org.springframework.context.annotation.Bean)

Example 2 with ToStringSerializer

use of com.fasterxml.jackson.databind.ser.std.ToStringSerializer in project ocvn by devgateway.

the class MvcConfig method objectMapperBuilder.

@Bean
public Jackson2ObjectMapperBuilder objectMapperBuilder() {
    Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
    //builder.featuresToEnable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
    SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
    builder.serializationInclusion(Include.NON_EMPTY).dateFormat(dateFormatGmt);
    builder.serializerByType(GeoJsonPoint.class, new GeoJsonPointSerializer());
    builder.serializerByType(ObjectId.class, new ToStringSerializer());
    builder.defaultViewInclusion(true);
    return builder;
}
Also used : Jackson2ObjectMapperBuilder(org.springframework.http.converter.json.Jackson2ObjectMapperBuilder) ToStringSerializer(com.fasterxml.jackson.databind.ser.std.ToStringSerializer) GeoJsonPointSerializer(org.devgateway.ocds.web.rest.serializers.GeoJsonPointSerializer) SimpleDateFormat(java.text.SimpleDateFormat) Bean(org.springframework.context.annotation.Bean)

Aggregations

ToStringSerializer (com.fasterxml.jackson.databind.ser.std.ToStringSerializer)2 SimpleDateFormat (java.text.SimpleDateFormat)2 GeoJsonPointSerializer (org.devgateway.ocds.web.rest.serializers.GeoJsonPointSerializer)2 Bean (org.springframework.context.annotation.Bean)2 Jackson2ObjectMapperBuilder (org.springframework.http.converter.json.Jackson2ObjectMapperBuilder)2