GetJsonStringFromSymbol
![GetJsonStringFromSymbol 1:](Images/jpg/13478376971__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 of a structure instance, for example.
The maximum size of the string returned by the method is 255 characters. With longer strings, the method will return a NULL string. In this case the method CopyJsonStringFromSymbol() must be used.
Syntax
METHOD GetJsonStringFromSymbol : STRING(255)
VAR_IN_OUT CONSTANT
sDatatype : STRING;
END_VAR
VAR_INPUT
nData : UDINT;
pData : PVOID;
END_VAR
VAR_OUTPUT
hrErrorCode : HRESULT;
END_VAR
Return value
Name | Type |
---|---|
GetJsonStringFromSymbol | STRING(255) |
Inputs
Name | Type |
---|---|
nData | UDINT |
pData | PVOID |
/
Inputs/Outputs
Name | Type |
---|---|
sDatatype | STRING |
Outputs
Name | Type |
---|---|
hrErrorCode | HRESULT |
Sample call:
sBuffer := fbJsonDataType.GetJsonStringFromSymbol('ST_Values',SIZEOF(stValues), ADR(stValues));