Browse Source

Updated md files

pull/12923/head
mpetrov 1 year ago
parent
commit
3b925df445
  1. 52
      ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-json_fn.md
  2. 54
      ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-url_fn.md

52
ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-json_fn.md

@ -1,9 +1,11 @@
### Expressions ### Expressions
#### JSON Path #### JSON Path
The expression field is used to specify the path for extracting data from an HTTP response message. The expression field is used to specify the path for extracting data from an incoming HTTP request body.
JSONPath expressions specify the items within a JSON structure (which could be an object, array, or nested combination of both) that you want to access. These expressions can select elements from JSON data on specific criteria. Here's a basic overview of how JSONPath expressions are structured: JSONPath expressions specifies the items within a JSON structure (which could be an object, array, or nested combination of both) that you want to access.
These expressions can select elements from JSON data on specific criteria.
Basic overview of how JSONPath expressions are structured:
- `$`: The root element of the JSON document; - `$`: The root element of the JSON document;
- `.`: Child operator used to select child elements. For example, $.store.book ; - `.`: Child operator used to select child elements. For example, $.store.book ;
@ -11,9 +13,7 @@ JSONPath expressions specify the items within a JSON structure (which could be a
#### Examples #### Examples
For example, if we want to extract the device name from the following message, we can use the expression below: Incoming request body:
HTTP response message:
```json ```json
{ {
@ -25,30 +25,26 @@ HTTP response message:
"temp": 12.2, "temp": 12.2,
"hum": 56, "hum": 56,
"status": "ok" "status": "ok"
} },
"rxInfo": [
{
"rssi": 50,
"snr": 3
},
{
"rssi": 22,
"snr": 1
}
]
} }
``` ```
<br>
JSON Path Expression Examples below shows on how to extract values from incoming request body.
`${sensorModelInfo.sensorName}`
Converted data:
`AM-123`
To extract all data from the message above, use:
`${data}`
Converted data:
`{"temp": 12.2, "hum": 56, "status": "ok"}`
To extract a specific value, such as the temperature, use:
`${data.temp}`
Converted data:
`12.2` | JSON Path Expression | Extracted data |
|---------------------------------|---------------------------------------------|
| `${sensorModelInfo.sensorName}` | `AM-123` |
| `${data}` | `{"temp": 12.2, "hum": 56, "status": "ok"}` |
| `${$.data.temp}` | `12.2` |
| `${$.rxInfo[0].rssi}` | `50` |

54
ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-url_fn.md

@ -1,54 +0,0 @@
### Expressions
#### Request URL
JSONPath expressions are used to construct URL addresses for sending messages.
JSONPath expressions specify items within a JSON structure (objects, arrays, or a nested combination) that you wish to access. These expressions can select elements from JSON data on specific criteria. Here's a basic overview of how JSONPath expressions are structured:
- `$`: The root element of the JSON document;
- `.`: Child operator used to select child elements. For example, $.store.book ;
- `[]`: Child operator used to select child elements. $['store']['book'] accesses the book array within a store object;
#### Examples
For example, if we want to extract the device name from the following message, we can use the expression below:
HTTP response message:
```json
{
"sensorModelInfo": {
"sensorName": "AM-123",
"sensorType": "myDeviceType"
},
"data": {
"temp": 12.2,
"hum": 56,
"status": "ok"
}
}
```
Url Expression:
`${sensorModelInfo.sensorName}`
Converted data:
`AM-123`
To extract all data from the message above, use:
`${data}`
Converted data:
`{"temp": 12.2, "hum": 56, "status": "ok"}`
To extract specific data (e.g., "temperature"), use:
`${data.temp}`
Converted data:
`12.2`
Loading…
Cancel
Save