Package org.czeal.jsonfilter
Interface Filter
- All Known Implementing Classes:
ExclusionFilter
,InclusionFilter
public interface Filter
A filter interface for processing JSON elements by either including or excluding
specified nodes.
Implementations of this interface define how filtering is applied to a given JSON structure based on a set of rules provided in a string format.
The filtering rules are specified as a comma-separated string where nested fields can be defined using parentheses. Implementations may use this structure to determine whether elements should be retained or removed from the resulting JSON.
Example
"a,b(c,d)"
- Includes/excludes top-level elementa
and the sub-elementsc
andd
insideb
."x(y)"
- Includes/excludes onlyx.y
, keeping other elements inx
.
Implementing classes may vary in behavior, such as including only specified elements (inclusion filtering) or removing specified elements (exclusion filtering).
- Author:
- Hideki Ikeda
-
Method Summary
-
Method Details
-
apply
Applies the filtering strategy to the targetsource
based on the givennodes
.- Parameters:
source
- The source JSON element to filter.nodes
- A comma-separated string defining allowed JSON nodes to include. Each node can specify nested fields using parentheses.- Returns:
- A new
JsonElement
instance built by filtering thesource
object based on the givennodes
string.
-