JPath / JSON Processing
Data Query from JSON Data Packages
JPath is designed for server responses containing JSON. JPath and works on the same principle as XPath function, and allows easy access to data contained in JSON data packages, thus enabling the OPC Router to extract and provide the desired information whenever and whereever needed.
That’s how easy it is.
The transfer object of the JSON Plug-in facilitates easy access to incoming JSON strings.
The query requires a JSON string as data entry field. In the transfer ojbect, a JPath query is created and formulated, and is structured as items and parameters.
The items of the data fields are made available as output, for subsequent objects.
The JSON plug-in does not come with its own trigger functions. Instead it uses the standard trigger functions of the OPC Router.
The JSON plug-in directly addresses JSON items.
JSON Server Plug-in Application Examples
Production and process data packaged in JSON
The JSON format is the common formatting for data in the environment of NoSQL, Cloud, MQTT, Web etc.. The JSON documents can map complex structures and are readable as normal text due to the encoding in UTF-8 (or UTF-16/-32).
If production or process data are to be read from controllers via OPC UA and transferred as JSON to a target system, they are converted using the JSON Write transfer object of the OPC router. The nested JSON document structure is defined in the JSON Write transfer object. The individual fields of the document can then be written to with OPC UA data in the OPC Router connection. The JSON document filled with production and process data is transferred to the target system as a complete document (e.g. MongoDB, InfluxDB, MQTT, REST).
Extract data from JSON documents for OPC and SQL
In addition to sending JSON structured data from the industry 4.0 environment to the NoSQL and Cloud environments, JSON also provides data for the production of these systems via JSON document. The received JSON documents must then be evaluated and broken down into data fields and structures that can be processed by the production systems involved. The JSON Read transfer object of the OPC router reads the JSON document structure for this purpose and provides the available data fields and structures intuitively for selection. Individual data fields are selected for transfer to controllers and devices via OPC UA. For the transfer to SQL based databases (SQL Server, ORACLE, MySQL) whole sub-structures and arrays can be selected and transferred directly to the database. A practical example can be found in our tutorial article on transferring weather data from the online portal OpenWeatherMap to a SQL database.