Skip to content
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

Add yet another SerializationFeature, WRITE_ABSENT_MAP_VALUES #818

Closed
cowtowncoder opened this issue Jun 5, 2015 · 3 comments
Closed

Add yet another SerializationFeature, WRITE_ABSENT_MAP_VALUES #818

cowtowncoder opened this issue Jun 5, 2015 · 3 comments

Comments

@cowtowncoder
Copy link
Member

With addition of new JsonInclude.Include option, NON_ABSENT, and existing dualism between POJOs, java.util.Maps, seems like we will also need WRITE_ABSENT_MAP_VALUES.
Its semantics are such that if enabled, it will exclude serialization of both Java nulls AND "referential nulls" (like Optional.absent() and new AtomicReference<>(null)); if disabled, WRITE_NULL_MAP_VALUES is consulted.

Yes, things get bit hairy, and it would be cleaner if instead we could set JsonInclude.Include value instead. But it has to do.

@cowtowncoder
Copy link
Member Author

After trying to implement this, I realized one challenge: while it is relatively straight-forward to work for Map-valued properties, as they typically have proper value type declaration, it will not work quite right for root-Maps where type is generally assumed to be Object.
Given that users are probably going to be surprised by one case working, others not, I will defer implementation for now.

@cowtowncoder
Copy link
Member Author

Quick note: with 2.7, there is the new concept of content inclusion (as distinct from older value inclusion) -- that is, related but separated checks for container, its contents -- this may be easier to support. Or possibly even works as is; if latter, needs to be tested to verify that specific combination of inclusion definitions works as expected.

@cowtowncoder
Copy link
Member Author

Actually, I think that other new features (like config overrides for JsonInclude) should take care of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant