JSON Encode / Decode Processors

The “JSON Encode” and “JSON Decode” processors are installed with the UA Office Link Application. The processors take one or more values as inputs and either encode the inputs into a JSON object string value or decode a JSON object string value into individual values for further processing in the task pipeline.

Add to Task

Add the respective processor to a task by dragging it from the “Build” panel onto the task’s “Task Builder” panel.

../../_images/processor-jsonencodedecode.png

JSON Encoder Configuration

Select the JSON Encoder processor item in the “Task Builder” panel to view its properties.

../../_images/processor-jsonencode-edit.png

You can change the following properties.

  • Processor Topic Name

    You can change the processor topic name to suit. When changing the topic name to something other than “JSON Encoder” then the “JSON” output tag will be renamed to carry the name of the processor topic. This may be helpful when the “JSON” output tag is connected to “generic” output topics that carry the tag name forward.

  • Representative JSON object

    Enter a representative JSON object string into the entry field provided and press “Apply”. The JSON Encoder processor will generate input tag connection points for each of the properties within the JSON object. When tag values are sent to these input tag connection points then the JSON Encoder will generate a “JSON” output string with property values replaced with actual values.

JSON Decoder Configuration

Select the JSON Decoder processor item in the “Task Builder” panel to view its properties.

../../_images/processor-jsondecode-edit.png

You can change the following properties.

  • Processor Topic Name

    You can change the processor topic name to suit. This may be helpful when the topic connection point is used to connect to “generic” output topics that carry the topic name forward.

  • Representative JSON object

    Enter either a list of property names (or JSON paths) or a representative JSON object string into the entry field provided and press “Apply”. The JSON Decoder processor will expect any connected input tag to be of type “string”, which needs to be a JSON object containing the entered property names or a JSON object matching the entered representative JSON object. When tags are connected to the processor then output tags are generated for each entered property or for each property within the representative JSON object.

Examples

Encode JSON

In the following example, signals are received from the OPC UA Connector, then encoded into a JSON object and sent to the MQTT connector.

../../_images/processor-jsonencode-example.png

Decode JSON

In the following example, a JSON object string containing Sine signals is received from the MQTT Connector, then decoded into individual values and sent to the CSV connector. Note that you can connect multiple tags to the same JSON Decoder.

../../_images/processor-jsondecode-example.png