Details
-
Type:
Improvement
-
Status:
In Progress
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.9.2
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
When using @JsonUnwrapped annotation on a property, the filter is applied on the property itself, thus filtering everything.
Let's have a look at the following example :
{ "name" : "home", "latitude" : 127, "longitude" : 345 }to classes defined as:
@JsonFilter("myFilter")
class Place
@JsonFilter("myFilter")
class Location
If setting "myFilter" to return only "name" and "latitude", it returns only :
{ "name" : "home" }While I expect to have :
{ "name" : "home", "latitude" : 127, }This is due to the fact that "FilterExceptFilter.serializeAsField" method just checks for the name (but did not checked for the unwrap).
Changing one line of the method "FilterExceptFilter.serializeAsField" :
From
if (_propertiesToInclude.contains(writer.getName())) {
To
if (_propertiesToInclude.contains(writer.getName()) || writer instanceof UnwrappingBeanPropertyWriter) {
This works as expected
Activity
| Field | Original Value | New Value |
|---|---|---|
| Status | Open [ 1 ] | In Progress [ 3 ] |