Overview
With the aid of the PLC library Tc3_JsonXml, SAX and DOM parser technologies can be used to create and navigate through JSON and XML documents. See the chapter Terms and general information for further details.
Function blocks
The following table is intended to provide an initial overview of the various options available for working with JSON and XML documents in Tc3_JsonXml.
Function block | Typical applications | Recommendation |
|---|---|---|
JSON documents with only a few changes. | The FB_JsonDomParser is used when a JSON document needs to be loaded and modified in just a few places. | |
JSON documents with many changes. | The FB_JsonDynDomParser is used when numerous changes are made to a JSON document without releasing the document between modifications. | |
Read JSON documents sequentially and process them as they are parsed. | The FB_JsonSaxReader is used when a JSON document needs to be processed sequentially and its contents need to be evaluated via Callback methods during parsing. | |
Generate JSON documents step by step. | The FB_JsonSaxWriter is used when a JSON document needs to be set-up sequentially. | |
Generate JSON documents step by step and with proper formatting. | The FB_JsonSaxPrettyWriter is used when a JSON document needs to be generated in the same way as with the SAX writer, but formatted with additional whitespace to improve readability. | |
Convert PLC data structures or symbols to JSON and write them back. | The FB_JsonReadWriteDataType is used when generating the JSON representation of a symbol or structure, or when transferring the contents of a JSON object into an equivalent data structure. | |
Load and edit XML documents. | Use FB_XmlDomParser to load, navigate, read, and modify XML documents. |