|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > JSON - Parser > Parser-Operations > !Array Operations > PSJ. - JSON Operations |
SPR Script Language
PSJ.AppendNull
Appends a null value to a JSON array at a specified path.
Intention
The PSJ.AppendNull command in SPR adds a null value to the end of a JSON array located at a given path ($$PATH) within a JSON document identified by $$DOC). Optionally, it returns a status code in $$RET to indicate success or failure. It’s like telling your robot to tack an empty placeholder onto a list in your JSON structure.
For example, appending a null value to an array at "root.array" in document 100 adds "null" to that list.
Illustration
📝 Append Null: PSJ.AppendNull|100|root.array adds "null" to the array at "root.array".
📝 With Status: PSJ.AppendNull|200|data.list|$$STAT adds "null" to "data.list" and stores the status in $$STAT.
Syntax
PSJ.AppendNull|$$DOC|$$PATH[|$$RET]
Parameter Explanation
P1 - $$DOC - (Variable, Numeric)
The identifier of the JSON document (e.g., $$DOC as "100"). Required.
P2 - $$PATH - (Variable, String)
The dot-separated path to the array in the JSON document (e.g., $$PATH as "root.array"). Required.
P3 - $$RET - (Variable, Numeric, Optional)
The variable to store the status code (e.g., $$RET as "$$STAT"). Returns 0 for success or a positive value indicating an error. If omitted, the status is returned but not stored.
Examples
'***********************************
' Sample 1: Append Null to an Array
PSJ.AppendNull|100|root.array
' Adds "null" to the array at "root.array" in document 100
MBX.Ready
'***********************************
' Sample 2: Append Null with Status
PSJ.AppendNull|200|data.list|$$STAT
' Adds "null" to "data.list" and checks status
IF $$STAT <> 0 THEN PRT.Error: $$STAT
MBX.Ready
Remarks
- $$RET returns 0 for success; non-zero values indicate errors (e.g., invalid path or non-array target).
- Use PSJ.ErrCode for detailed error information if $$RET is not 0.
Limitations
- $$PATH must point to an existing array in the JSON document.
- $$DOC must be a valid document identifier.
See also: