-
-
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
s to keep empty arrays and objects
#715
Comments
Something like this seems to work, but I really don't know the code base so i can't be sure it makes sense. I see |
One quick note: is this related to/same as #708 ? If so I wish I had time to work on it; help would be appreciated. |
I had another look this morning and I think so. I'll try and open up a PR soon. I think the code that I linked in the gist works fine for the builder side. Filtering the parsers are a little wow. I'll keep poking at it. There's a whole giant switch statement I haven't looked at yet. |
Yes, the code is.... scary. It violates my usual "never write as clever code as you can since the person debugging code must be twice as clever as the person who wrote it (hence write only half as clever you could)". |
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
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
This creates two new method on `TokenFilter` which you can override to decide if empty arrays and objects should be included or excluded. Closes #715
Include version information for Jackson version you use: We use 2.10.4 but 2.13 doesn't support this either
Maybe this is possible in a way I don't know about, but I was hoping I could write a
TokenFilter
that could preserve empty arrays and objects. It looks like now if aTokenFilter#includeProperty
doesn't returnINCLUDE_ALL
for an empty array then the array is removed. I'd love it if theTokenFilter
could make that choice- maybe something like adding this toTokenFilter
:There is already a
filterFinishArray
but I don't think I can control the underlying filter with it. And I'm not sure if I can tell if the filter has filtered the contents of the array or not.The text was updated successfully, but these errors were encountered: