GetJsonStringFromSymbol

GetJsonStringFromSymbol 1:

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

GetJsonStringFromSymbol 2: Return value

Name

Type

GetJsonStringFromSymbol

STRING(255)

GetJsonStringFromSymbol 3: Inputs

Name

Type

nData

UDINT

pData

PVOID

GetJsonStringFromSymbol 4:/GetJsonStringFromSymbol 5: Inputs/Outputs

Name

Type

sDatatype

STRING

GetJsonStringFromSymbol 6: Outputs

Name

Type

hrErrorCode

HRESULT

Sample call:

sBuffer := fbJsonDataType.GetJsonStringFromSymbol('ST_Values',SIZEOF(stValues), ADR(stValues));