You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/sql-manual/sql-functions/scalar-functions/json-functions/json-exists-path.md
+46-8
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
1
2
---
2
3
{
3
4
"title": "JSON_EXISTS_PATH",
@@ -24,23 +25,60 @@ specific language governing permissions and limitations
24
25
under the License.
25
26
-->
26
27
27
-
## json_exists_path
28
28
29
-
### description
29
+
##Description
30
30
31
31
It is used to judge whether the field specified by json_path exists in the JSON data. If it exists, it returns TRUE, and if it does not exist, it returns FALSE
| `<json_str>` | The element to be included in the JSON array. It can be a value of any type, including NULL. If no element is specified, an empty array is returned.
47
+
|`<path>`| The JSON path to be judged. If it is NULL, then return NULL. |
40
48
41
-
Refer to [json tutorial](../../sql-reference/Data-Types/JSON.md)
49
+
## Return Values
50
+
If it exists, return TRUE; if it does not exist, return FALSE.
Copy file name to clipboardexpand all lines: docs/sql-manual/sql-functions/scalar-functions/json-functions/json-extract.md
+124-68
Original file line number
Diff line number
Diff line change
@@ -24,109 +24,165 @@ specific language governing permissions and limitations
24
24
under the License.
25
25
-->
26
26
27
-
## json_extract
28
-
29
-
### description
30
-
31
-
#### Syntax
32
27
28
+
## Description
29
+
JSON_EXTRACT is a series of functions that extract the field specified by json_path from JSON data and provide different series of functions according to the type of the field to be extracted.
30
+
31
+
* JSON_EXTRACT returns the VARCHAR type for a json string of the VARCHAR type.
32
+
* JSON_EXTRACT_ISNULL returns the BOOLEAN type indicating whether it is a json null.
33
+
* JSON_EXTRACT_BOOL returns the BOOLEAN type.
34
+
* JSON_EXTRACT_INT returns the INT type.
35
+
* JSON_EXTRACT_BIGINT returns the BIGINT type.
36
+
* JSON_EXTRACT_LARGEINT returns the LARGEINT type.
37
+
* JSON_EXTRACT_DOUBLE returns the DOUBLE type.
38
+
* JSON_EXTRACT_STRING returns the STRING type.
39
+
40
+
## Alias
41
+
* JSONB_EXTRACT is the same as JSON_EXTRACT.
42
+
* JSONB_EXTRACT_ISNULL is the same as JSON_EXTRACT_ISNULL.
43
+
* JSONB_EXTRACT_BOOL is the same as JSON_EXTRACT_BOOL.
44
+
* JSONB_EXTRACT_INT is the same as JSON_EXTRACT_INT.
45
+
* JSONB_EXTRACT_BIGINT is the same as JSON_EXTRACT_BIGINT.
46
+
* JSONB_EXTRACT_LARGEINT is the same as JSON_EXTRACT_LARGEINT.
47
+
* JSONB_EXTRACT_DOUBLE is the same as JSON_EXTRACT_DOUBLE.
48
+
* JSONB_EXTRACT_STRING is the same as JSON_EXTRACT_STRING.
Alias functions have the same syntax and usage as the above functions, except for the function names.
44
76
45
-
json_extract functions extract field specified by json_path from JSON. A series of functions are provided for different datatype.
46
-
- json_extract with VARCHAR argument, extract and return VARCHAR datatype
47
-
- jsonb_extract extract and return JSON datatype
48
-
- json_extract_isnull check if the field is json null and return BOOLEAN datatype
49
-
- json_extract_bool extract and return BOOLEAN datatype
50
-
- json_extract_int extract and return INT datatype
51
-
- json_extract_bigint extract and return BIGINT datatype
52
-
- json_extract_largeint extract and return LARGEINT datatype
53
-
- json_extract_double extract and return DOUBLE datatype
54
-
- json_extract_STRING extract and return STRING datatype
55
-
77
+
## Parameters
78
+
| Parameter | Description |
79
+
|--------------|-----------------------------|
80
+
|`<json_str>`| The JSON-type parameter or field to be extracted. |
81
+
|`<path>`| The JSON path to extract the target element from the target JSON. |
56
82
json path syntax:
57
83
- '$' for json document root
58
84
- '.k1' for element of json object with key 'k1'
59
85
- If the key column value contains ".", double quotes are required in json_path, For example: SELECT json_extract('{"k1.a":"abc","k2":300}', '$."k1.a"');
60
86
- '[i]' for element of json array at index i
61
87
- Use '$[last]' to get the last element of json_array, and '$[last-1]' to get the penultimate element, and so on.
62
88
89
+
## Return Values
90
+
According to the type of the field to be extracted, return the data type of the specified JSON_PATH in the target JSON. Special case handling is as follows:
91
+
* If the field specified by json_path does not exist in the JSON, return NULL.
92
+
* If the actual type of the field specified by json_path in the JSON is inconsistent with the type specified by json_extract_t.
93
+
* if it can be losslessly converted to the specified type, return the specified type t; if not, return NULL.
63
94
64
-
Exception handling is as follows:
65
-
- if the field specified by json_path does not exist, return NULL
66
-
- if datatype of the field specified by json_path is not the same with type of json_extract_t, return t if it can be cast to t else NULL
0 commit comments