-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
Allow TokenFilter to preserve empty #729
Allow TokenFilter to preserve empty #729
Conversation
@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
Yes, 2.14 is perfect; I do indeed merge forward usually. |
Note: one of top items for me to get merged, not today probably but very soon. Thank you very much for your patience. |
@@ -432,6 +432,14 @@ public boolean includeEmbeddedValue(Object value) { | |||
return _includeScalar(); | |||
} | |||
|
|||
public boolean includeEmptyArray(boolean contentsFiltered) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add Javadocs, after merge.
return false; | ||
} | ||
|
||
public boolean includeEmptyObject(boolean contentsFiltered) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above: I will add Javadocs after merge.
Thanks so much for merging this one! And for cleaning the rough edges I left. |
This creates two new method on
TokenFilter
which 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