Add application property to customize Jackson default leniency #27547
Labels
status: superseded
An issue that has been superseded by another
type: enhancement
A general enhancement
Jackson provides a leniency setting for deserialization, which can be configured per property (using
@JsonFormat(lenient=OptBoolean.FALSE
)) or globally (perObjectMapper.setDefaultLeniency(false)
).This flag will become more useful as of (the not yet released) Jackson 2.13 per FasterXML/jackson-modules-java8#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'sJackson2ObjectMapperBuilder
type does not directly expose this property, a post-configurer is probably the simplest way to set this:The text was updated successfully, but these errors were encountered: