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 support for @JsonInclude(content=Include.NON_NULL) (and NON_EMPTY) for Maps #527

Closed
cowtowncoder opened this issue Aug 28, 2014 · 1 comment
Milestone

Comments

@cowtowncoder
Copy link
Member

(and other inclusion values)

Currently use of something like:

@JsonInclude(Include.NON_EMPTY)

only affects value itself. But for structured values (arrays, Collections, Maps), there is also the question of inclusion strategy for contents.
Currently the only way to control such inclusion is via global feature SerializationFeature.WRITE_NULL_MAP_VALUES, and that only affects handling of Maps.

But it would seem reasonable to add an additional property in @JsonInclude, say, contents, and modify structured type serializers to consider this for filtering.
The first one to use it with should be Map (and specialized variants like EnumMap). But due to amount of work involved, let's add support for arrays and Collections if and when specifically requested.

@cowtowncoder cowtowncoder changed the title Add support for @JsonInclude(contents=Include.NON_EMPTY) for Maps Add support for @JsonInclude(contents=Include.NON_NULL) (and NON_EMPTY) for Maps Oct 20, 2014
cowtowncoder added a commit that referenced this issue Oct 20, 2014
@cowtowncoder cowtowncoder added this to the 2.5.0 milestone Oct 20, 2014
@cowtowncoder
Copy link
Member Author

Implementation was slightly more involved than expected, but things work now.

Note, however, that #588 should be implemented too, to be able to properly cascade case of Maps that are empty of serializable values: that is, Maps where map.size() != 0 but where all entries are suppressed.

@cowtowncoder cowtowncoder changed the title Add support for @JsonInclude(contents=Include.NON_NULL) (and NON_EMPTY) for Maps Add support for @JsonInclude(content=Include.NON_NULL) (and NON_EMPTY) for Maps May 17, 2016
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