From 3b925df445da22512171d29ee8ee4673acf92829 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 19 Mar 2025 14:22:53 +0200 Subject: [PATCH] Updated md files --- .../en_US/widget/lib/gateway/rest-json_fn.md | 52 +++++++++--------- .../en_US/widget/lib/gateway/rest-url_fn.md | 54 ------------------- 2 files changed, 24 insertions(+), 82 deletions(-) delete mode 100644 ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-url_fn.md diff --git a/ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-json_fn.md b/ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-json_fn.md index fe41a2c610..32143694df 100644 --- a/ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-json_fn.md +++ b/ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-json_fn.md @@ -1,9 +1,11 @@ ### Expressions #### 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; - `.`: 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 -For example, if we want to extract the device name from the following message, we can use the expression below: - -HTTP response message: +Incoming request body: ```json { @@ -25,30 +25,26 @@ HTTP response message: "temp": 12.2, "hum": 56, "status": "ok" - } + }, + "rxInfo": [ + { + "rssi": 50, + "snr": 3 + }, + { + "rssi": 22, + "snr": 1 + } + ] } ``` +
-JSON Path 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 a specific value, such as the temperature, use: - -`${data.temp}` - -Converted data: +Examples below shows on how to extract values from incoming request body. -`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` | diff --git a/ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-url_fn.md b/ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-url_fn.md deleted file mode 100644 index a30deb6203..0000000000 --- a/ui-ngx/src/assets/help/en_US/widget/lib/gateway/rest-url_fn.md +++ /dev/null @@ -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`