jsonCreateObject creates a new, empty JSON object.
When the JSON object is no longer needed, it must be released using jsonFree.
Input:
None
Output:
o : SYSHANDLE
A handle to the JSON object.
Returns: INT
1
|
- Success
|
0
|
- Function is not supported.
|
-6
|
- Could not create JSON object, there may be too many in use.
|
Declaration:
FUNCTION jsonCreateObject : INT;
VAR_INPUT
o : ACCESS SYSHANDLE;
END_VAR;
Example:
INCLUDE rtcu.inc
PROGRAM test;
VAR
rc : INT;
arr : SYSHANDLE;
obj : SYSHANDLE;
END_VAR;
BEGIN
...
rc := jsonCreateArray(o := arr);
rc := jsonAddValueInt(o := arr, value := 123);
rc := jsonCreateObject(o := obj);
rc := jsonSetValueInt(o := obj, key := "Number", value := 42);
rc := jsonSetValue(o := arr, idx := 0, value := obj);
rc := jsonFree(o := obj);
...
END;
END_PROGRAM;
|