question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`@JsonValue` not considered when evaluating inclusion

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, Nov 11, 2020

I am planning to release one more rc, 2.12.0-rc2 within 1 week.

0reactions
mbenz89commented, Jun 29, 2021

@cowtowncoder I see. Thanks a lot for the elaboration!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found