This function will read the contents of the body of the request as a JSON structure.
Input:
req : SYSHANDLE
A handle to the request.
Output:
json : SYSHANDLE
A handle to the JSON structure created from the body content.
When the JSON structure is no longer needed, it must be released using jsonFree.
Returns: INT
1
|
|
- Success
|
0
|
|
- Not supported
|
-1
|
|
- Invalid request
|
-2
|
|
- The max number of JSON structures have already been created.
|
-3
|
|
- Failed to create JSON structure. Body content might not be valid JSON.
|
Declaration:
FUNCTION restReqBodyGetJSON : INT;
VAR_INPUT
req : SYSHANDLE;
json : ACCESS SYSHANDLE;
END_VAR;
Example:
FUNCTION CALLBACK devicesGetCallback: INT;
VAR_INPUT
req : SYSHANDLE;
resp : SYSHANDLE;
arg : DINT;
END_VAR;
VAR
json : SYSHANDLE;
rc : INT;
END_VAR;
...
rc := restRespBodyGetJSON(resp:=resp, json:=json);
...
rc := jsonFree(o:=json);
...
END_FUNCTION;
|