|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > JSON - Parser > Parser-Operations > PSJ. - JSON Operations |
SPR Script Language
Node Operations
Commands for manipulating individual nodes within JSON structures in the SPR Script Language.
Intention
The Node Operations chapter groups commands in the PSJ. library that are designed to manipulate individual nodes within JSON documents. These commands allow users to access, clone, duplicate, remove, replace, and traverse nodes, providing detailed control over the hierarchical structure of JSON data. This section is intended for users who need to manage specific nodes or navigate the JSON tree.
For example, cloning a node or removing a child node can be achieved using these commands, enabling precise modifications to the JSON hierarchy.
Illustration
📝 Clone a Node: PSJ.Clone|docHandle|nodeHandle|$$NEWNODE creates a copy of the specified node and stores the new handle in $$NEWNODE.
📝 Remove a Child: PSJ.RemoveChild|docHandle|parentHandle|childHandle removes the specified child node from its parent.
Commands
• PSJ.ChildAt - Retrieves a child node by its index.
• PSJ.ChildCount - Counts the number of child nodes under a parent node.
• PSJ.ChildIDs - Retrieves the IDs of child nodes as a string.
• PSJ.Clone - Creates a copy of a specified node.
• PSJ.DupTree - Duplicates a node and its entire subtree.
• PSJ.FindChild - Finds a child node by its key.
• PSJ.FreeTree - Frees a node and its subtree from memory.
• PSJ.GetByPath - Gets or creates a node by a specified path.
• PSJ.NextSib - Retrieves the next sibling node ID.
• PSJ.RemoveChild - Removes a child node from its parent.
• PSJ.ReplNode - Replaces a node at a specified path with a new node.
Remarks
- All node operations require a valid document handle and node identifier.
- Commands like PSJ.Clone and PSJ.DupTree support duplication, while PSJ.RemoveChild and PSJ.FreeTree handle removal and cleanup.
See also: