I have gone through many StackOverflow's questions and github's issues, but didn't get the solution of my problem. I have class as follow :
@JsonFilter("apiFilter")
Class Employee{
String id,
String name;
Address address,
}
@JsonFilter("apiFilter")
Class Address{
String id,
String city,
String state,
String country,
}
I want to filter the properties of Employee and its nested object Address properties using @JosnFilter while returning the response of API, where I am able to filter the properties of Employee with below set of codes
SimpleBeanPropertyFilter propertyFilter = SimpleBeanPropertyFilter.filterOutAllExcept("name", "address");
FilterProvider filters = new SimpleFilterProvider().addFilter("apiFilter", propertyFilter).setFailOnUnknownId(false);
But I need to filter the properties of nested object also using dot(.) For example "address.city" and
"address.state" will be passed in filterOutAllExcept("address.state","address.city") . I could not use a different filter for address as I need to filter property based on object reference dot(.) its properties like address.state
I have gone through these github issues but there is no recent update on the support of nested object properties by jackson.
https://github.com/FasterXML/jackson-core/issues/230
https://github.com/FasterXML/jackson-databind/issues/1040
https://github.com/spring-projects/spring-framework/issues/17187
Any suggestion would be a great help.. Thanks.