Using Embedded JSON Strings
- Last UpdatedNov 27, 2018
- 1 minute read
For OI Gateway G-2.0 and above, the MQTT subscriber supports embedded JSON strings, as well as strings at multiple nested levels (objects and arrays). Refer the examples of possible JSON string forms and the referenced values below.
Example 1: If TagX receives a JSON string of form { “Value1”: 1, “Value2”:2}
Values in the JSON string are referenced as follows:
|
Tag Reference |
Value |
|
TagX |
{ “Value1”: 1, “Value2”:2} |
|
TagX.Value1 |
1 |
|
TagX.Value2 |
2 |
Example 2: If TagA receives a JSON string of form { “Value1”: 1, “Value2”:{ “value3”: 2, “value4”: 3 }, “Value5”: [ 5, 6] }
Values in the JSON string are referenced as follows:
|
Tag Reference |
Value |
|
TagA |
{ “Value1”: 1, “Value2”:{ “value3”: 2, “value4”: 3 }, “Value5”: [ 5, 6]} |
|
TagA.Value1 |
1 |
|
TagA.Value2 |
{ “value3”: 2, “value4”: 3 } |
|
TagA.Value2.value3 |
2 |
|
TagA.Value2.value4 |
3 |
|
TagA.Value5 |
[5,6] |
|
TagA.Value5[0] |
5 |
|
TagA.Value5[1] |
6 |
Example 3: If TagA receives a JSON string of form [ “stringValue1”, “stringValue2”]
Values in the JSON string are referenced as follows:
|
Tag Reference |
Value |
|
TagS |
[ “stringValue1”, “stringValue2”] |
|
TagS[0] |
stringValue1 |
|
TagS[1] |
stringValue2 |