-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnwrappedPropertyHandler serializes empty JSON Objects #885
Comments
Filtering What is the ultimate goal here? That is, what is the problem in creating empty POJOs from empty JSON Objects? |
The ultimate goal is not have null values or null structures like i mentioned in the json output. So the problem is even if empty pojos are created by design during deserialization, then during serialization, even if i set JsonInclude.Include.NON_EMPTY on the pojo it still returns an empty structure ( i guess thats because the serializer do write START { and END } even if the pojo is empty ). I wanted to do this at deserializer level to make it cleaner. |
Oh. So just to make it clear; these settings have no effect on deserialization. But I understand what you would like to see for serialization: currently there is no way to prune out "empty" POJOs; only empty Now: I assume that POJOs in question do have properties, but those properties get filtered out, being empty. If so, the problem is that filtering checks are based on Java objects, and not on JSON -- given this, check for Would it be possible to add POJO definition here, just to make sure I understand the structure involved, and use of unwrapping? While I assumed it is not relevant, it is possible that some part of filtering might not be done same way for unwrapped values as for regular ones. |
Thanks. Yes, a way to determine empty pojos and skip them during serialization would work for us. Some sample pojo definitions i have: public class Details {
private Parking parking;
}
public class DetailsMixIn {
@JsonUnwrapped
private Parking parking;
}
public class Parking {
private String spaceFeeType;
private String spaceCost;
private String comment;
private List<String> types;
} |
@cowtowncoder any follow up on this. Do we have any pointers or jira for this feature. Thanks. |
@optimistdk No, there are no active plans to support feature for recursively figuring emptiness of POJOs. There may be an issue/RFE for (more) pluggable determination of exclusion with Actually; I thought I had filed an issue for "custom inclusion", but I can't seem to find it. |
Thank you. We will wait for availability of On Wed, Aug 5, 2015 at 10:26 PM, Tatu Saloranta [email protected]
|
#888 is now implemented for 2.9.0 -- assuming this will allow intended behavior. |
Whenever I use @JsonUnwrapped annotation, my deserialized beans still are created even if all child values are null. I do set my object mapper to not include empty fields.
All empty pojos annotated with @JsonUnwrapped are serialized as { } .
So I end up having lot of empty structures:
While debugging i found that processUnwrapped was creating empty beans even if all values ( even nested pojos ) were null.
Can this be fixed in UnwrappedPropertyHandler to not deserialize empty values ( or respect JsonInclude.Include.NON_EMPTY )
other ref: http://stackoverflow.com/questions/31735669/jackson-jsonunwrapped-creating-empty-beans
The text was updated successfully, but these errors were encountered: