net.minidev.json.actions.navigate.CopyPathsAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-smart-action Show documentation
Show all versions of json-smart-action Show documentation
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.
package net.minidev.json.actions.navigate;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import net.minidev.json.actions.path.TreePath;
import java.util.Collection;
import java.util.Stack;
/**
* Creates a copy of a {@link JSONObject} containing just the nodes on the paths specified.
*
* Specified paths that do not exist in the source object are ignored silently.
* Specifying an empty list of paths to navigate or only non-existent paths will result in an empty
* object being returned.
*
* See package-info for more details
*
* Example:
*
* To copy the branch k1.k2 from {k1:{k2:v1}, k3:{k4:v2}} instantiate the copier like so:
* new JSONObjectCopier("k1.k2")
* The resulting copy would be {k1:{k2:v1}}
*
* See unit tests for more examples
*
* @author [email protected]
* @since 15 March 2016.
*
*/
public class CopyPathsAction implements JSONNavigateAction {
protected JSONObject destTree;
protected JSONObject destBranch;
protected Stack