Title
spring.jackson.default-property-inclusion=non-empty is not applied in Spring Boot 4.0.0
Description
In Spring Boot 4.0.0, configuring:
spring:
jackson:
default-property-inclusion: non-empty
does not affect serialization behavior.
Even when the property inclusion is set to non-empty, Jackson still includes empty strings and null values in the serialized output.
Reproduction
Configuration (application.yml)
spring:
jackson:
default-property-inclusion: non-empty
Code
private final JsonMapper jsonMapper; // Injected
@Override
public void run(String... args) throws Exception {
final Map<String, Object> map = new HashMap<>();
map.put("key1", "");
map.put("key2", null);
map.put("key3", " ");
jsonMapper.writeValueAsString(map);
// Expected output: {"key3":" "}
// Actual output: {"key1":"","key2":null,"key3":" "}
}
Expected Behavior
Keys with empty values ("") or null values should be excluded from serialization when default-property-inclusion is set to non-empty.
Actual Behavior
Empty and null values are still included in the serialized JSON output.
Environment
- Spring Boot: 4.0.0
- Jackson: (default version bundled with Spring Boot 4)
Notes
This configuration worked as expected in prior Spring Boot versions.
It appears that spring.jackson.default-property-inclusion is no longer applied or is being ignored in Spring Boot 4.
Title
spring.jackson.default-property-inclusion=non-emptyis not applied in Spring Boot 4.0.0Description
In Spring Boot 4.0.0, configuring:
does not affect serialization behavior.
Even when the property inclusion is set to
non-empty, Jackson still includes empty strings andnullvalues in the serialized output.Reproduction
Configuration (
application.yml)Code
Expected Behavior
Keys with empty values (
"") ornullvalues should be excluded from serialization whendefault-property-inclusionis set tonon-empty.Actual Behavior
Empty and null values are still included in the serialized JSON output.
Environment
Notes
This configuration worked as expected in prior Spring Boot versions.
It appears that
spring.jackson.default-property-inclusionis no longer applied or is being ignored in Spring Boot 4.