@@ -206,23 +206,26 @@ Example:
206206
207207** Description**
208208
209- ` json_set(json_string, [key, value...]) ` Inserts or updates one or more keys and their corresponding values from the specified JSON object.
209+ ` json_set(json_string, array(<path>, < value>, ...)) ` Inserts or updates one or more values at the corresponding paths in the specified JSON object.
210210
211- ** Arguments type:** JSON_STRING, List<STRING, STRING>
211+ ** Argument type:**
212+ - \< json_string\> must be a JSON_STRING.
213+ - \< path\> must be a STRING.
214+ - \< value\> can be a JSON_STRING.
212215
213216** Return type:** JSON_STRING
214217
215218An updated JSON object format.
216219
217220Example:
218221
219- os> source=people | eval updated = json_set('{"a":[{"b":1},{"b":2}]}', '$.a[*].b', 3 ) | head 1 | fields updated
222+ os> source=people | eval updated = json_set('{"a":[{"b":1},{"b":2}]}', array( '$.a[*].b', '3', '$.a', '{"c":4}') ) | head 1 | fields updated
220223 fetched rows / total rows = 1/1
221- +-------------------------+
222- | updated |
223- +-------------------------+
224- | {"a":[{"b":3},{"b":3}]} |
225- +-------------------------+
224+ +--------------------------------- +
225+ | updated |
226+ +--------------------------------- +
227+ | {"a":[{"b":3},{"b":3},{"c":4} ]} |
228+ +--------------------------------- +
226229
227230
228231### ` JSON_DELETE `
@@ -267,9 +270,12 @@ Example:
267270
268271** Description**
269272
270- ` json_append(json_string, [path_key, list of values to add ]) ` appends values to end of an array within the json elements. Return the updated json object after appending.
273+ ` json_append(json_string, [path_key, value,... ]) ` appends values to end of an array at path_key within the json elements. Return the updated json object after appending.
271274
272- ** Argument type:** JSON_STRING, List<STRING >
275+ ** Argument type:**
276+ - \< json_string\> must be a JSON_STRING.
277+ - \< path\> must be a STRING.
278+ - \< value\> can be a JSON_STRING.
273279
274280** Return type:** JSON_STRING
275281
@@ -285,23 +291,23 @@ Append adds the value to the end of the existing array with the following cases:
285291
286292Example:
287293
288- os> source=people | eval append = json_append(`{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}`,array( 'student', '{"name":"Tomy","rank":5}')) | head 1 | fields append
294+ os> source=people | eval append = json_append(`{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}`, 'student', array( '{"name":"Tomy","rank":5}')) | head 1 | fields append
289295 fetched rows / total rows = 1/1
290296 +-----------------------------------------------------------------------------------------------------------------------------------+
291297 | append |
292298 +-----------------------------------------------------------------------------------------------------------------------------------+
293299 |{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2},{"name":"Tomy","rank":5}]} |
294300 +-----------------------------------------------------------------------------------------------------------------------------------+
295301
296- os> source=people | eval append = json_append(`{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}`,array( 'teacher', 'Tom', 'Walt')) | head 1 | fields append
302+ os> source=people | eval append = json_append(`{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}`, 'teacher', array( 'Tom', 'Walt')) | head 1 | fields append
297303 fetched rows / total rows = 1/1
298304 +-----------------------------------------------------------------------------------------------------------------------------------+
299305 | append |
300306 +-----------------------------------------------------------------------------------------------------------------------------------+
301307 |{"teacher":["Alice","Tom","Walt"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]} |
302308 +-----------------------------------------------------------------------------------------------------------------------------------+
303309
304- os> source=people | eval append = json_append(`{"school":{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}}`,array( 'school.teacher', array('Tom', 'Walt'))) | head 1 | fields append
310+ os> source=people | eval append = json_append(`{"school":{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}}`, 'school.teacher', array( array('Tom', 'Walt'))) | head 1 | fields append
305311 fetched rows / total rows = 1/1
306312 +-------------------------------------------------------------------------------------------------------------------------+
307313 | append |
@@ -313,9 +319,12 @@ Example:
313319
314320** Description**
315321
316- ` json_extend(json_string, [path_key, list of values to flatten ]) ` extends the values to end of an array within the json elements. Return the updated json object after extending.
322+ ` json_extend(json_string, [path_key, value,... ]) ` extends values to end of an array at path_key within the json elements. Return the updated json object after extending.
317323
318- ** Argument type:** JSON_STRING, List<STRING >
324+ ** Argument type:**
325+ - \< json_string\> must be a JSON_STRING.
326+ - \< path\> must be a STRING.
327+ - \< value\> can be a JSON_STRING.
319328
320329** Return type:** JSON_STRING
321330
@@ -331,7 +340,7 @@ Extends adds the value to the end of the existing array with the following cases
331340
332341Example:
333342
334- os> source=people | eval extend = json_extend(`{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}`, 'student', '{"name":"Tommy","rank":5}') | head 1 | fields extend
343+ os> source=people | eval extend = json_extend(`{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}`, 'student', array( '{"name":"Tommy","rank":5}') ) | head 1 | fields extend
335344 fetched rows / total rows = 1/1
336345 +-----------------------------------------------------------------------------------------------------------------------------------+
337346 | extend |
@@ -347,7 +356,7 @@ Example:
347356 |{"teacher":["Alice","Tom","Walt"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]} |
348357 +-----------------------------------------------------------------------------------------------------------------------------------+
349358
350- os> source=people | eval extend = json_extend(`{"school":{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}}`, 'school.teacher', array('Tom', 'Walt')) | head 1 | fields extend
359+ os> source=people | eval extend = json_extend(`{"school":{"teacher":["Alice"],"student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}}`, 'school.teacher', array(array( 'Tom', 'Walt') )) | head 1 | fields extend
351360 fetched rows / total rows = 1/1
352361 +-------------------------------------------------------------------------------------------------------------------------+
353362 | extend |
0 commit comments