Terms and general information

JSON document

The following section shows a JSON document as an example:

{
  "VariableNameX": 0.0,
  "VariableNameY": 0.0,
  "VariableNameZ": 0.0
}

SAX (Simple API for XML)

SAX was originally developed for handling XML documents, but can also be used for other data formats such as JSON. A SAX parser treats the data to be read or written as a sequential data stream. When reading a data stream, defined callback methods are called, which then return the corresponding contents of the data stream. A SAX parser is therefore also referred to as an event-based parser. The events occurring (callback methods) are stateless, i.e. they are not dependent on the preceding events. The advantage of this is that the XML document never has to be completely contained in the memory and the application can react “on the fly” via the callbacks.

DOM (Document Object Model)

DOM is a specification for accessing XML documents, but can also be used for other data formats such as HTML or JSON. The interface is based on a defined object model, which must be valid for the interface to be used correctly. This object model represents a document, e.g. a JSON document, in the form of a tree structure in the memory, which can then be used to navigate through the document. DOM allows you to navigate between nodes, create, move, and delete nodes, and read, modify, or delete node content. At the end of processing, a new JSON or XML document is generated from the finalized tree structure. The advantage here is that no own data housekeeping needs to be created with the read-in data, since the data exist in the DOM and can be continuously accessed.

SJsonValue

When using SJsonValue, please note that these are temporary pointers. Permanent use through storage and reuse is not intended. In particular, note that updating the pointer of a "parent node" always invalidates the pointers of the following “child nodes”.

JSON Web Token (JWT)

JSON Web Token (JWT) is an open standard (based on RFC 7519) that defines a compact and self-describing format for securely transmitting information between communication devices in the form of a JSON object. The authenticity of the transmitted information can be verified and ensured, since a JWT is provided with a digital signature. The signature can involve a shared secret (via an HMAC algorithm) or a public/private key (via RSA).

The most common application example for JWT is the authorization of a device or user for a service. Once a user has logged into the service, all further requests to the service include the JWT. Based on the JWT, the service can then decide which additional services or resources the user may access. This means, for example, that single sign-on solutions can be implemented in cloud services.

The Tc3_JsonXml library provides a function for creating a JWT via the FB_JwtEncode method.

Metadata

The Tc3_JsonXml library contains the FB_JsonReadWriteDataType function block, which enables automatic generation of metadata by means of PLC attributes.

{
  "Values": {
    "VariableNameX": 0.0,
    "VariableNameY": 0.0,
    "VariableNameZ": 0.0
  },
  "MetaData": {
    "VariableNameX": {
      "Unit": "A"
    },
    "VariableNameY": {
      "Unit": "V"
    },
    "VariableNameZ": {
      "Unit": "mA"
    }
  }
}

See also: samples > Tc3JsonXmlSampleJsonDataType.

In order to use UTF-8 characters, e.g. in the automatic generation of metadata via the FB_JsonReadWriteDataType function block, the check box for UTF-8 support in ADS Symbolic must be enabled in the TwinCAT project. To do this, double-click on SYSTEM in the project tree, open the Settings tab and activate the corresponding check box.

Terms and general information 1: