Jackson provides a leniency setting for deserialization, which can be configured per property (using @JsonFormat(lenient=OptBoolean.FALSE)) or globally (per ObjectMapper.setDefaultLeniency(false)).

This flag will become more useful as of (the not yet released) Jackson 2.13 per https://github.com/FasterXML/jackson-modules-java8/issues/212, as disabling it will cause Jackson to reject dates with time components (e.g. "2007-12-03T10:15:30", "2007-12-03T10:15:30Z") when deserializing a LocalDate value. Disallowing these time components can be useful, as including them can lead to unintended issues truncating the time part results in the wrong date due to time zone discrepancies between the source & target systems.

In light of this, it would be handy if there were a way to set the default value of this lenient property through a Spring Boot application property.

Workaround

Right now, this property can be configured using a custom Jackson2ObjectMapperBuilderCustomizer bean. Since Spring's Jackson2ObjectMapperBuilder type does not directly expose this property, a post-configurer is probably the simplest way to set this:

@Configuration
public class CustomizedJacksonConfiguration {
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer nonLenientObjectMapperBuilderCustomizer() {
        return builder -> builder.postConfigurer(
                objectMapper -> objectMapper.setDefaultLeniency(false));
    }
}

Comment From: lower-case

Hi @wilkinsona I'm new to project and I'd like to work on this. I've started working on the code, will raise PR shortly. Thanks!

Comment From: snicoll

Closing in favour of PR #27659