`@JsonValue` ignores name filters on the enclosing property
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with the bean serializer’s lookup of name filters for properties serialized through @JsonValue, then trace how contextual properties expose their member; the report identifies the change from #6076 and says #3647 covers filters on the accessor. Reproduce with the supplied Holder example and verify that ignore, include, and plain each serialize only keep. PR #6414 proposes a fix, so check its status before starting.
Written by the indexing model from the issue text.
Description
I used DeepSeek to translate this report into English.
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
Jackson Databind 3.3.0 ignores @JsonIgnoreProperties and @JsonIncludeProperties on an enclosing property when the property value is serialized through @JsonValue. The example below writes drop under both ignore and include. The directly serialized plain property still filters it out.
Version Information
Reproduced with 3.3.0 on JDK 17. The same example works in 3.2.4 and at 3ad2bb7e, and first fails at 6a17bd06 (#6076).
Reproduction
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonIncludeProperties;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonValue;
import tools.jackson.databind.json.JsonMapper;
class Repro {
@JsonPropertyOrder({"keep", "drop"})
record Payload(int keep, int drop) {}
static class Wrapper {
@JsonValue
public Object value() {
return new Payload(1, 2);
}
}
@JsonPropertyOrder({"ignore", "include", "plain"})
static class Holder {
@JsonIgnoreProperties("drop")
public Wrapper ignore = new Wrapper();
@JsonIncludeProperties("keep")
public Wrapper include = new Wrapper();
@JsonIgnoreProperties("drop")
public Payload plain = new Payload(1, 2);
}
public static void main(String[] args) {
System.out.println(JsonMapper.builder().build().writeValueAsString(new Holder()));
}
}
Actual output on 3.3.0
{"ignore":{"keep":1,"drop":2},"include":{"keep":1,"drop":2},"plain":{"keep":1}}
Expected behavior
All three properties should contain only keep.
{"ignore":{"keep":1},"include":{"keep":1},"plain":{"keep":1}}
Additional context
After #6076, getMember() on the contextual property returns the @JsonValue accessor. The bean serializer looks up name filters on that member and misses the annotations on the enclosing property. #3647 covered filters declared on the accessor itself.
PR #6414 proposes a fix for Bean and Map values.
- Dominant language
- Java
- Stars
- 3.8k
- Forks
- 1.6k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 59
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from FasterXML/jackson-databind
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
FasterXML/jackson-databind#6443 ·
Maintainers usually reply within 1 day
-
to-evaluate
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
FasterXML/jackson-databind#6340 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 12/100
FasterXML/jackson-databind#6442 ·
Maintainers usually reply within 1 day
-
`@JsonUnwrapped` value with `EXTERNAL_PROPERTY` type id silently deserialized as `null` (or misleading unknown-property error)Possibly taken @wn1331 claimed this 2 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
FasterXML/jackson-databind#6421 ·
Maintainers usually reply within 1 day
-
`StdConvertingSerializer` looks up and contextualizes delegate serializer for every value when converter output type is dynamicPossibly taken @wn1331 claimed this 2 days ago. Open3.x
Difficulty 4/5 3-5 days Newbie friendliness 25/100
FasterXML/jackson-databind#6395 ·
Maintainers usually reply within 1 day
All issues in FasterXML/jackson-databind
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
johanhaleby/occurrent#1505 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
finos/fluxnova-bpm-platform#387 ·
Maintainers usually reply within 4 days
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 Under an hour Newbie friendliness 84/100
cpp-best-practices/project_validator#251 ·
Maintainers usually reply within 1 day