Package net.minidev.json.actions
Class PathsRetainer
- java.lang.Object
-
- net.minidev.json.actions.PathsRetainer
-
public class PathsRetainer extends java.lang.ObjectRetains branches of nodes of aJSONObjectmatching the list of user-specified paths.A path to copy must be specified in the n-gram format - a list of keys from the root down separated by dots: K0[[[[.K1].K2].K3]...]
A key to the right of a dot is a direct child of a key to the left of a dot. Keys with a dot in their name are not supported.Example:
to retain the field k1.k2 in the
JSONObject{k1:{k2:v1}, k3:{k4:v2}} instantiate the retainer like so: new JSONObjectCleaner("k1.k2") The resulting object would be {k1:{k2:v1}}See unit tests in JSONObjectRetainerTest for more examples
-
-
Field Summary
Fields Modifier and Type Field Description protected PathDelimiterpathDelimiterprotected java.util.List<java.lang.String>pathsToRetain
-
Constructor Summary
Constructors Constructor Description PathsRetainer(java.lang.String... pathsToRetain)PathsRetainer(java.util.List<java.lang.String> pathsToRetain)PathsRetainer(JSONArray pathsToRetain)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JSONObjectretain(JSONObject object)PathsRetainerwith(PathDelimiter pathDelimiter)
-
-
-
Field Detail
-
pathsToRetain
protected java.util.List<java.lang.String> pathsToRetain
-
pathDelimiter
protected PathDelimiter pathDelimiter
-
-
Constructor Detail
-
PathsRetainer
public PathsRetainer(JSONArray pathsToRetain)
-
PathsRetainer
public PathsRetainer(java.util.List<java.lang.String> pathsToRetain)
-
PathsRetainer
public PathsRetainer(java.lang.String... pathsToRetain)
-
-
Method Detail
-
with
public PathsRetainer with(PathDelimiter pathDelimiter)
-
retain
public JSONObject retain(JSONObject object)
-
-