Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Home
  • Knowledge base
  • Contact Us
  • Home
  • Scripting & Variables

Using payloads & wrapping out JSON parameters

Written by Benjamin Pinnerup

Updated at March 27th, 2023

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Installation & Technical information
    Introduction SIA Connect Standalone SIA Connect ANY-Ware Cellular & WiFi connectivity
  • Configuration in the Web UI
    Getting started with the UI Connectors Instances Items Mapping Data System Network Tools & Add-ons DigiCert IoT Trust Manager
  • Connectors
    Siemens S7 Azure IoT Ethernet/IP Mitsubishi MELSEC OPC-UA Server SQL MQTT Omron Host Link REST API Omron FINS Keyence Beckhoff TwinCAT BACnet Virtual OPC-UA Client MS SQL File M-Bus Modbus
  • Scripting & Variables
    Data formatting
  • Developers
    API documentation Shadow API
  • Tutorials & Guides
    InfluxDB AWS IoT Core - Amazon Web Services Microsoft Power BI KaaIoT Siemens S7 AVEVA Insight SIA Connect Demo Rack Grafana Azure
  • General
+ More

Table of Contents

Condition example Custom value example Post-processing example Payload and result examples

Articles in this section:

  • System variables
  • Instance variables
  • Item variables
  • Post processing of data
  • Using payloads & wrapping out JSON parameters

SIA can process JSON payloads to fit into the individual needs of the user. The payloads can be used as a comparison in the Condition part of the mapping, as a value in the Custom value part of the mapping, or in the post-processing of an item

Condition example

This section will expand on how to use a single value from a payload as the condition for a mapping. This is useful when the user wants to utilize various parameters from a payload to trigger one or more mappings

We will be using this payload as the example:

{
    "Value" : INT-value
}

We want a mapping, where the condition specifies that the "Value" has to be 1 before we take any action

This way, if we send the payload:

{
    "Value" : 1
}

Then the mapping will trigger.

If the value is not 1, then the mapping will not trigger 


Custom value example

We will use the same payload as before, but this time we will unwrap the value and send it to another item as the value. This is useful when you are reading payloads and want to send raw values to another instance/item

In the custom value of the mapping we will input %VALUE.Value% to get the raw value connected to this specific variable:

If we then input this payload in the sender item:

{ 
    "Value" : 1 
}

We will see that the receiver item does not receive the full payload, but only the value connected to that variable:


Post-processing example

A payload can be unwrapped and stored as the value of the item reading that payload. This is done by using the Post-Processing

We will be using the same example as before:

{ 
    "Value" : 1 
}

In the Post-Processing of the item, we will input the following:

%VALUE.value%

The item should look like this:

Our item is now only reading the INT-value from the value-variable:


This method is especially useful when reading larger payloads, and the user only wants one specific piece of data



Payload and result examples

Below are some examples on how to unwrap specific values from specific payloads. The syntax will vary slightly, depending on how the payload is structured

Payload Payload example User input
Printed value
One object, one variable {
"value1":"1"
}
%VALUE.value1% 1
One object, many variables {
"value1":"1",
"value2":"2",
"value3":"3"
}
%VALUE.value2% 2
Array without objects
["1","2","3"]
%VALUE[0]%
1
Array with one object [{
    "value1": "1",
    "value2": "2",
    "value3": "3"
}]
%VALUE[0].value3% 3
Array with many objects [{
    "value1": "1"
}, {
    "value2": "2"
}, {
    "value3": "3"
}]
%VALUE[1].value2% 2
Array inside object {
    "value1": "1",
    "value2": "2",
    "value3": [{
        "valueX": "x",
        "valueY": "y"
    }]
}
%VALUE.value3[0].valueX% x


transport load payload use

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Post processing of data
  • Item variables
  • System variables
  • Instance variables

0
0
Expand