GetJsonFromSymbol
![GetJsonFromSymbol 1:](Images/jpg/13478376459__Web.jpg)
This method generates the corresponding JSON representation of a symbol. In contrast to the AddJsonValueFromSymbol() method, the result is not written to an instance of the function block FB_JsonSaxWriter, but to a string variable. The method receives as its input parameters the data type name of the symbol as well as the address and size of the source symbol, e.g. of a structure instance. The address and size of the destination buffer that contains the JSON representation of the symbol after the call are transferred as further input parameters.
Syntax
METHOD GetJsonFromSymbol : BOOL
VAR_IN_OUT CONSTANT
sDatatype : STRING;
END_VAR
VAR_INPUT
nData : UDINT;
pData : PVOID;
nJson : REFERENCE TO UDINT;
pJson : POINTER TO STRING;
END_VAR
VAR_OUTPUT
hrErrorCode : HRESULT;
END_VAR
Return value
Name | Type |
---|---|
GetJsonFromSymbol | BOOL |
Inputs
Name | Type |
---|---|
nData | UDINT |
pData | PVOID |
nJson | REFERENCE TO UDINT |
pJson | POINTER TO STRING |
/
Inputs/Outputs
Name | Type |
---|---|
sDatatype | STRING |
Outputs
Name | Type |
---|---|
hrErrorCode | HRESULT |
![]() | Input parameter nJson The input parameter nJson contains the size of the destination buffer when the method is called, and the size of the actually written JSON object in the destination buffer when the method call is completed. |
Sample call:
fbJsonDataType.GetJsonFromSymbol('ST_Values',SIZEOF(stValues), ADR(stValues), nBufferLength, ADR(sBuffer));