jsonAddValue (Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

2.10.00


jsonAddValue adds the provided JSON value to the end of the given JSON array, growing the size of the array by 1.

 

Input:

o : SYSHANDLE

A handle to the JSON array to add the value to.

 

value : SYSHANDLE

The value to add.

 

Returns: INT

1

- Success.

0

- Function is not supported.

-3

- Invalid handle.

-4

- Not an array

-7

- Could not find value

-99

- Failed to add value

 

 

Declaration:

FUNCTION jsonAddValue : INT;
VAR_INPUT
   o     : SYSHANDLE;
   value : SYSHANDLE;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
   rc  : INT;
   arr SYSHANDLE;
   obj SYSHANDLE;
END_VAR;
 
BEGIN
   ...
   // Create array
   rc := jsonCreateArray(:= arr);
   // Create object
   rc := jsonCreateObject(:= obj);
   // Add integer to object
   rc := jsonSetValueInt(:= objkey := "Number", value := 42);
   // Add object to array
   rc := jsonAddValue(:= arrvalue := obj);
   // Release object handle
   rc := jsonFree(:= obj);
   ...
END;
 
END_PROGRAM;