@Bean public Jackson2ObjectMapperBuilderCustomizer configProtobufSerializer() { return new Jackson2ObjectMapperBuilderCustomizer() { @Override public void customize( Jackson2ObjectMapperBuilder builder) { builder.serializerByType(Message.class, new JsonSerializer<Message>(){ @Override public void serialize(Message message, JsonGenerator generator, SerializerProvider provider) throws IOException { if(message == null) return; JsonJacksonFormat format = new JsonJacksonFormat(); format.print(message, generator); }}); } }; }
@Bean public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilder() { return builder -> { TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); df.setTimeZone(tz); builder .failOnEmptyBeans(false) .failOnUnknownProperties(false) .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .dateFormat(df); }; }
@Bean public Jackson2ObjectMapperBuilderCustomizer configBuilder() { return new Jackson2ObjectMapperBuilderCustomizer() { @Override public void customize( Jackson2ObjectMapperBuilder builder) { builder.findModulesViaServiceLoader(true) .dateFormat(new SimpleDateFormat("yyyy-MM-dd")); } }; }
/** * Customize the Spring auto-configured Jackson ObjectMapper (not used by Camel rest). * In this example we set marshaling rules for BasicDataSource.class */ @Bean public Jackson2ObjectMapperBuilderCustomizer customObjectMapper() { return new Jackson2ObjectMapperBuilderCustomizer() { @Override public void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder) { jacksonObjectMapperBuilder .mixIn(BasicDataSource.class, BasicDataSourceMixIn.class) .indentOutput(true); } }; }
@Bean public Jackson2ObjectMapperBuilderCustomizer mapperBuilderCustomizer() { return mapperBuilder -> { mapperBuilder.serializationInclusion(Include.NON_NULL); mapperBuilder.featuresToEnable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); }; }
@Bean public Jackson2ObjectMapperBuilderCustomizer jacksonCustomizer() { return new Jackson2ObjectMapperBuilderCustomizer() { @Override public void customize(Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder) { jackson2ObjectMapperBuilder.serializers(new ZonedDateTimeSerializer(ISO_FIXED_FORMAT)); } }; }
@Bean public Jackson2ObjectMapperBuilderCustomizer jacksonCustomConfig() { return builder -> { DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); builder.failOnEmptyBeans(false) .failOnUnknownProperties(false) .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .dateFormat(df); }; }
@Bean public Jackson2ObjectMapperBuilderCustomizer jacksonCustomizer() { return jackson2ObjectMapperBuilder -> jackson2ObjectMapperBuilder.serializers(new ZonedDateTimeSerializer(ISO_FIXED_FORMAT)); }