`@JsonValue` not considered when evaluating inclusion
See original GitHub issueI have an object (a links
holder) that is essentially a container around a java.util.Map
. The map is annotated with @JsonValue
, and this behaves as expected (the map is dumped as a JSON object inline).
However, I only want this included when the map is non-empty, so I annotated the getLinks()
method with @JsonInclude(NON_EMPTY)
. However, it appears that the inclusion filter is applied before the value substitution, so it is always included even as {}
.
I’m using Jackson 2.11.2 (managed via Spring Boot).
@Data
class Wrapper {
@JsonValue
Map<String, String> values;
}
@Data
class TopLevel {
@JsonInclude(NON_EMPTY)
Wrapper nested;
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Security update for jackson-databind, jackson-dataformats ...
... system + '@JsonValue' not considered when evaluating inclusion + Make some java platform modules optional + Add support for serializing ...
Read more >JSON Conditions
Use the JSON_EXISTS condition to test whether a specified JSON value exists in JSON data. This condition returns TRUE if the JSON value...
Read more >A Vocabulary for Structural Validation of JSON - JSON Schema
A string instance is considered valid if the regular expression matches the instance successfully. Recall: regular expressions are not ...
Read more >JSON is Case Sensitive. You Don't Have to Be. - Couchbase
You must have learned capitalization rules in your grammar school, but the real-world search is not so sensitive to capitalization.
Read more >JSON functions and operators — Trino 403 Documentation
In lax mode, any non-array items resulting from the evaluation of the input ... The json_exists function determines whether a JSON value satisfies...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am planning to release one more rc, 2.12.0-rc2 within 1 week.
@cowtowncoder I see. Thanks a lot for the elaboration!