Allow TokenFilter to preserve empty#729
Merged
cowtowncoder merged 1 commit intoFasterXML:2.14from Jan 3, 2022
Merged
Conversation
Contributor
Author
|
@cowtowncoder sorry it took me so long to get to it. I just cherry-picked this into 2.14 and it went in clean and the tests passed. I opened a new PR because I'm not really sure how to swing the old PR to the new branch. Is it right for me to target 2.14 instead of master? Will you forward port if you decide to merge? |
This creates two new method on `TokenFilter` which you can override to
decide if empty arrays and objects should be included or excluded. An
override like this, for example, will include all arrays and objects
that were sent empty but strip any arrays or objects that were
*filtered* to be empty:
```
@OverRide
public boolean includeEmptyArray(boolean contentsFiltered) {
return !contentsFiltered;
}
@OverRide
public boolean includeEmptyObject(boolean contentsFiltered) {
return !contentsFiltered;
}
```
The default to preserve backwards compatibility is to always *exclude*
empty objects.
Closes FasterXML#715
Member
|
Yes, 2.14 is perfect; I do indeed merge forward usually. |
Member
|
Note: one of top items for me to get merged, not today probably but very soon. Thank you very much for your patience. |
cowtowncoder
reviewed
Jan 3, 2022
| return _includeScalar(); | ||
| } | ||
|
|
||
| public boolean includeEmptyArray(boolean contentsFiltered) { |
Member
There was a problem hiding this comment.
I will add Javadocs, after merge.
cowtowncoder
reviewed
Jan 3, 2022
| return false; | ||
| } | ||
|
|
||
| public boolean includeEmptyObject(boolean contentsFiltered) { |
Member
There was a problem hiding this comment.
Same as above: I will add Javadocs after merge.
cowtowncoder
reviewed
Jan 3, 2022
Contributor
Author
|
Thanks so much for merging this one! And for cleaning the rough edges I left. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This creates two new method on
TokenFilterwhich you can override todecide if empty arrays and objects should be included or excluded. An
override like this, for example, will include all arrays and objects
that were sent empty but strip any arrays or objects that were
filtered to be empty:
The default to preserve backwards compatibility is to always exclude
empty objects.
Closes #715