@@ -69,12 +69,13 @@ ____________
69
69
Description
70
70
>>>>>>>>>>>
71
71
72
- Usage: `json_extract(doc, path) ` Extracts a JSON value from a json document based on the path specified.
72
+ Usage: `json_extract(doc, path[, path] ) ` Extracts a JSON value from a json document based on the path specified.
73
73
74
74
Argument type: STRING, STRING
75
75
76
76
Return type: STRING/BOOLEAN/DOUBLE/INTEGER/NULL/STRUCT/ARRAY
77
77
78
+ - Up to 3 paths can be provided, and results of each `path ` with be returned in an ARRAY.
78
79
- Returns an ARRAY if `path ` points to multiple results (e.g. $.a[*]) or if the `path ` points to an array.
79
80
- Return null if `path ` is not valid, or if JSON `doc ` is MISSING or NULL.
80
81
- Throws SemanticCheckException if `doc ` or `path ` is malformed.
@@ -95,18 +96,26 @@ Example::
95
96
| json empty string | | null |
96
97
+---------------------+-------------------------------------+-------------------+
97
98
98
- > source=json_test | where test_name="json nested list" | eval json_extract=json_extract('{"a":[{"b":1},{"b":2}]}', '$.b[1].c')
99
+ os > source=json_test | where test_name="json nested list" | eval json_extract=json_extract('{"a":[{"b":1},{"b":2}]}', '$.b[1].c')
99
100
fetched rows / total rows = 1/1
100
101
+---------------------+-------------------------------------+--------------+
101
102
| test_name | json_string | json_extract |
102
103
|---------------------|-------------------------------------|--------------|
103
104
| json nested list | {"a":"1","b":[{"c":"2"},{"c":"3"}]} | 3 |
104
105
+---------------------+-------------------------------------+--------------+
105
106
106
- > source=json_test | where test_name="json nested list" | eval json_extract=json_extract('{"a":[{"b":1},{"b":2}]}', '$.b[*].c')
107
+ os > source=json_test | where test_name="json nested list" | eval json_extract=json_extract('{"a":[{"b":1},{"b":2}]}', '$.b[*].c')
107
108
fetched rows / total rows = 1/1
108
109
+---------------------+-------------------------------------+--------------+
109
110
| test_name | json_string | json_extract |
110
111
|---------------------|-------------------------------------|--------------|
111
112
| json nested list | {"a":"1","b":[{"c":"2"},{"c":"3"}]} | [2,3] |
112
113
+---------------------+-------------------------------------+--------------+
114
+
115
+ os> source=json_test | where test_name="json nested list" | eval json_extract=json_extract('{"a":[{"b":1},{"b":2}]}', '$.a', '$.b[*].c')
116
+ fetched rows / total rows = 1/1
117
+ +---------------------+-------------------------------------+--------------+
118
+ | test_name | json_string | json_extract |
119
+ |---------------------|-------------------------------------|--------------|
120
+ | json nested list | {"a":"1","b":[{"c":"2"},{"c":"3"}]} | [1,[2,3]] |
121
+ +---------------------+-------------------------------------+--------------+
0 commit comments