jsonCreateArray (Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

2.10.00


jsonCreateArray creates a new, empty JSON array.

 

When the JSON array is no longer needed, it must be released using jsonFree.

 

Input:

None

 

Output:

o : SYSHANDLE

A handle to the JSON array.

 

Returns: INT

1

- Success

0

- Function is not supported.

-6

- Could not create JSON array, there may be too many in use.

 

 

Declaration:

FUNCTION jsonCreateArray : INT;
VAR_INPUT
   o     : ACCESS SYSHANDLE;
END_VAR;

 

 

Example:

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