PSJ. - JSON Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > JSON - Parser > Parser-Operations > !Node Operations >

PSJ. - JSON Operations

PSJ.NextSib

PreviousTopNext


SPR Script Language

 

PSJ.NextSib

Retrieves the next sibling node ID of a given node.

 

Intention

 

The PSJ.NextSib command in SPR retrieves the node ID of the next sibling of a specified node, identified by $$NID. Optionally, it stores the result in a variable specified by $$RTN. This command is useful for traversing sibling nodes within a JSON structure under the same parent.

 

For example, if node 50 is part of an array or object, this command returns the ID of the next node in the sequence, or 0 if it’s the last sibling.

 

Illustration

📝 Get Next Sibling: PSJ.NextSib|50 retrieves the next sibling ID of node 50.
📝 With Return Variable: PSJ.NextSib|75|$$SIB stores the next sibling ID of node 75 in $$SIB.

 

Syntax

 

PSJ.NextSib|$$NID[|$$RTN]

 

Parameter Explanation

 

P1 - $$NID - (Variable, Numeric)

The ID of the node whose next sibling is to be retrieved (e.g., $$NID as "50"). Required.

 

P2 - $$RTN - (Variable, Numeric, Optional)

The variable to store the next sibling’s node ID (e.g., $$RTN as "$$SIB"). Returns a positive node ID on success, or 0 if no next sibling exists. If omitted, the ID is returned but not stored.

 

Examples

 

'***********************************

' Sample 1: Get Next Sibling

PSJ.NextSib|50

' Retrieves the next sibling ID of node 50

MBX.Ready

'***********************************

' Sample 2: Store Next Sibling ID

PSJ.NextSib|75|$$SIB

' Stores the next sibling ID of node 75 in $$SIB

IVV.$$SIB!0

 MBX.Next sibling ID: $$SIB

ELS.

 PRT.No next sibling found

EIF.

'***********************************

 

Remarks

 

- Returns 0 if $$NID has no next sibling (e.g., it’s the last child or has no parent).

- Operates within the same parent node; does not traverse unrelated structures.

 

Limitations

 

- $$NID must be a valid node ID within a JSON document.

- Returns 0 for root nodes or nodes without siblings.

 

See also:

 

PSJ.FindChild