JSON Encode / Decode Processors

The “JSON Encode” and “JSON Decode” processors are installed with the Dataristix 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.

The “JSON Value Properties Encoder” processor takes any input value and encodes it’s value properties. Value properties are generated at the source of data and consist of the source timestamp (UTC), a status code (aligned with the OPC UA status code definition) and the actual value. The encoded string is a JSON object with properties “Value”, “Timestamp”, and “Status”.

See also: Value Properties Decoder Processor.

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 Value Properties Encoder Configuration

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

You can change the following properties.

  • Processor Topic Name

    You can change the processor topic name to suit.

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

Encode Value Properties as JSON payloads

In the following example, values are received from the OPC UA Connector. Value properties as received from the OPC UA server are encoded into a JSON payload and then forwarded to the MQTT Connector.

../_images/processor-jsonvaluepropertiesencoder-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