public class PathsRetainer extends Object
JSONObject
matching 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
Modifier and Type | Field and Description |
---|---|
protected PathDelimiter |
pathDelimiter |
protected List<String> |
pathsToRetain |
Constructor and Description |
---|
PathsRetainer(net.minidev.json.JSONArray pathsToRetain) |
PathsRetainer(List<String> pathsToRetain) |
PathsRetainer(String... pathsToRetain) |
Modifier and Type | Method and Description |
---|---|
net.minidev.json.JSONObject |
retain(net.minidev.json.JSONObject object) |
PathsRetainer |
with(PathDelimiter pathDelimiter) |
protected PathDelimiter pathDelimiter
public PathsRetainer(net.minidev.json.JSONArray pathsToRetain)
public PathsRetainer(String... pathsToRetain)
public PathsRetainer with(PathDelimiter pathDelimiter)
public net.minidev.json.JSONObject retain(net.minidev.json.JSONObject object)
Copyright © 2020 Chemouni Uriel. All rights reserved.