AddJsonValueFromSymbol
![AddJsonValueFromSymbol 1:](Images/jpg/13478373899__Web.jpg)
This method generates the JSON representation of a PLC data structure on an FB_JsonSaxWriter object. The method receives as its input parameters the instance of the FB_JsonSaxWriter function block, the data type name of the structure, and the address and size of the source structure instance. As a result, the FB_JsonSaxWriter instance contains a valid JSON representation of the structure.
Syntax
METHOD AddJsonValueFromSymbol : BOOL
VAR_IN_OUT
fbWriter : FB_JsonSaxWriter;
END_VAR
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 |
---|---|
AddJsonValueFromSymbol | BOOL |
Inputs
Name | Type |
---|---|
nData | UDINT |
pData | PVOID |
/
Inputs/Outputs
Name | Type |
---|---|
fbWriter | FB_JsonSaxWriter |
sDatatype | STRING |
Outputs
Name | Type |
---|---|
hrErrorCode | HRESULT |
A complete sample of how to use this method can be found in section Tc3JsonXmlSampleJsonDataType.
Sample call:
fbJsonSaxWriter.ResetDocument()
fbJsonDataType.AddJsonValueFromSymbol(fbJsonSaxWriter,'ST_Values',SIZEOF(stValues), ADR(stValues));