Package net.minidev.json.actions.traverse
Traverse all the nodes in a
JSONObject and process them
The traversal starts at the root and moves breadth-first down the branches. The TreeTraverser accepts a JSONTraverseAction and provides callback hooks at each
significant step which the JSONTraverseAction may use
to process the nodes.
The TreeTraverser assumes that paths in the tree
which the JSONObject represents are 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.
Sample usage:
TraverseAction tAction = new TraverseAction(){...};
JSONTraverser jsonTrv = new JSONTraverser(tAction);
jsonTrv.traverse(new JSONObject(...));
Object result = tAction.result();
-
Interface Summary Interface Description JSONTraverseAction An interface for a processing action on the nodes of aJSONObjectwhile traversing it.TreeTraverseAction<M extends java.util.Map<java.lang.String,java.lang.Object>,L extends java.util.List<java.lang.Object>> An interface for a processing action on the nodes of aTreeTraverseActiontree while traversing it. -
Class Summary Class Description JSONTraverser Traverses every node of aJSONObjectKeysPrintAction A traverse action that prints keys during JSON traversal.LocatePathsJsonAction Searches for paths in aJSONObjectand returns those foundRemoveElementsJsonAction Removes key:value elements from aJSONObject.RemovePathsJsonAction Removes branches from aJSONObject.RetainPathsJsonAction Retain branches or parts of branches matching a specified list of paths.TreeTraverser<M extends java.util.Map<java.lang.String,java.lang.Object>,L extends java.util.List<java.lang.Object>> Traverses every node of a tree made up of a combination ofMaps andLists