AddJsonValueFromSymbol

AddJsonValueFromSymbol 1:

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

AddJsonValueFromSymbol 2: Return value

Name

Type

AddJsonValueFromSymbol

BOOL

AddJsonValueFromSymbol 3: Inputs

Name

Type

nData

UDINT

pData

PVOID

AddJsonValueFromSymbol 4:/AddJsonValueFromSymbol 5: Inputs/Outputs

Name

Type

fbWriter

FB_JsonSaxWriter

sDatatype

STRING

AddJsonValueFromSymbol 6: 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));