@JsonIgnoreProperties should support nested properties
See original GitHub issueIs your feature request related to a problem? Please describe. It seems that there is no easy way to use the @JsonIgnoreProperties for nested properties. A similar case was #690 but it seems there is no way to do it with annotation.
Describe the solution you’d like Allowing a syntax with dots to go down a level with @JsonIgnoreProperties.
Usage example
class A {
int id;
double value;
}
class B {
String name;
A anObject;
}
class C {
@JsonIgnoreProperties({ "anObject.id" })
List<B> aList;
}
Would produce a JSON like:
{
"aList": [
{
"name": "...",
"anObject": {
"value": 42.0
},
},
{
"name": "...",
"anObject": {
"value": 42.0
}
}
]
}
Additional context This will especially useful for JPA entities with bi-directional mapping, where you can directly return the instance without copying to model to filter some values.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Jackson @JsonIgnoreProperties targeting nested attributes
In this example, I want that subAttributeC is not included in the serialization of a ParentObject - but this same subAttributeC still need...
Read more >Mapping Nested Values with Jackson - Baeldung
This tutorial will demonstrate how to handle inclusion of subtype metadata and ignoring properties inherited from superclasses with Jackson.
Read more >Developers - @JsonIgnoreProperties should support nested ...
JsonIgnoreProperties should support nested properties. ... It seems that there is no easy way to use the @JsonIgnoreProperties for nested properties.
Read more >Unrecognized field, not marked as ignorable - JSON Parsing ...
Alternatively, you can also use @JsonIgnoreProperties annotation to ignore undeclared properties. The @JsonIgnoreProperties is a class-level annotation in ...
Read more >Ignore property of object in list property of a class
What I want to have is a field level annotation as such. · This is so as to prevent recursion based on the...
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
No plans to ever implement this (due to delegating design, will not be possible with current Jackson architecture), closing.
@JsonFilter
only allow you to do it programmatically.I was looking for an anwser that yould be useful coupled with Spring MVC.