Skip to content

Conversation

@nik9000
Copy link
Contributor

@nik9000 nik9000 commented Dec 16, 2021

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 #715

@nik9000
Copy link
Contributor Author

nik9000 commented Dec 16, 2021

@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
@cowtowncoder
Copy link
Member

Yes, 2.14 is perfect; I do indeed merge forward usually.

@cowtowncoder
Copy link
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 cowtowncoder merged commit 8bed4d8 into FasterXML:2.14 Jan 3, 2022
return _includeScalar();
}

public boolean includeEmptyArray(boolean contentsFiltered) {
Copy link
Member

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) {
Copy link
Member

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.

@nik9000
Copy link
Contributor Author

nik9000 commented Jan 4, 2022

Thanks so much for merging this one! And for cleaning the rough edges I left.

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

Successfully merging this pull request may close these issues.

Allow TokenFilters to keep empty arrays and objects

2 participants