Provide configuration properties for Jackson read and write features that are common to multiple formats#48870
Conversation
In Spring Boot 3 write-bigdecimal-as-plain was managed by application property.
It does not work in Spring Boot 4 that way and requires custom Java `@Configuration`.
Configuration via application property is automatically catch by WebMvcTest.
It gives a high level of trust, because vanilla WebMvcTest may verify that plain BigDecimal works.
With custom Java `@Configuration`, the configuration must be added to WebMvcTest. It introduces doubt it really works in production, because
test looks rigged to produce the desired result.
Anyway, when working with BigDecimal it's typical IMHO to prefer plain, and it would be nice to configure it as easy as in Spring Boot 3
Goal is
spring:
jackson:
stream:
write:
write-bigdecimal-as-plain: true
Signed-off-by: michaldo <[email protected]>
|
Thanks for the PR. While I can see that I'm reluctant to add property support for low-level input and output stream-related features just to provide a property to control how big decimals are written. @cowtowncoder, have I misunderstood |
Signed-off-by: michaldo <[email protected]>
|
@wilkinsona There may be slight misunderstanding of distinction b/w
Hence Having said that, I think |
|
@cowtowncoder, I had indeed misunderstood and should have paid more attention to the class-level javadoc. Thanks for the correction. |
wilkinsona
left a comment
There was a problem hiding this comment.
Thanks for the PR, @michaldo. I've left a few comments for your consideration.
...-jackson/src/main/java/org/springframework/boot/jackson/autoconfigure/JacksonProperties.java
Outdated
Show resolved
Hide resolved
...-jackson/src/main/java/org/springframework/boot/jackson/autoconfigure/JacksonProperties.java
Outdated
Show resolved
Hide resolved
...-jackson/src/main/java/org/springframework/boot/jackson/autoconfigure/JacksonProperties.java
Outdated
Show resolved
Hide resolved
.../test/java/org/springframework/boot/jackson/autoconfigure/JacksonAutoConfigurationTests.java
Show resolved
Hide resolved
Signed-off-by: michaldo <[email protected]>
|
I applied all suggestion, but after that code asymmetry is visible (or more visible) It would look more consistent if all protocol specific properties are separated class or all are nested class |
Thanks.
The code has its current structure due to the way in which Jackson is structured. Jackson can always read and write JSON as the JSON-specific classes like |
Signed-off-by: michaldo <[email protected]> See gh-48870
Apply the format-agnostic read and write feature properties to all supported mappers (CBOR, JSON, and XML), not just JSON. See gh-48870
|
Thanks very much, @michaldo. This is now on |
In Spring Boot 3 write-bigdecimal-as-plain was managed by application property.
It does not work in Spring Boot 4 that way and requires custom Java
@Configuration.Configuration via application property is automatically catch by WebMvcTest. It gives a high level of trust, because vanilla WebMvcTest may verify that plain BigDecimal works.
With custom Java
@Configuration, the configuration must be added to WebMvcTest. It introduces doubt it really works in production, because test looks rigged to produce the desired result.Anyway, when working with BigDecimal it's typical IMHO to prefer plain, and it would be nice to configure it as easy as in Spring Boot 3
Goal is