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
* PPL: Add the json_extend command
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* PPL: add json_set function
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* scalafmt
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Remove comment
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Update JSON_APPEND, JSON_EXTEND, JSON_SET
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Consolidate nested function calls
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Add IT tests for json_set, json_expand
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Fix examples
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Fix IT tests
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Fix unit tests
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Fix syntax errors in IT tests
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Add IT tests for flatten calls
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Refactor nested traverse
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Update ppl-json.md examples
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
* Re-add missing import
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
---------
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
Copy file name to clipboardExpand all lines: docs/ppl-lang/functions/ppl-json.md
+86-9Lines changed: 86 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,14 +202,39 @@ Example:
202
202
| null |
203
203
+----------------+
204
204
205
+
### `JSON_SET`
206
+
207
+
**Description**
208
+
209
+
`json_set(json_string, array(path1, value1, path2, value2, ...))` Inserts or updates one or more values at the corresponding paths in the specified JSON object.
`json_delete(json_string, [keys list])` Deletes json elements from a json object based on json specific keys. Return the updated object after keys deletion.
235
+
`json_delete(json_string, array(key1, key2, ...))` Deletes json elements from a json object based on json specific keys. Returns the updated object after keys deletion.
`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, array(key1, value1, key2, value2, ...))` appends values to end of an array at key within the json elements. Returns the updated json object after appending.
274
+
`json_append` is identical to `json_extend` function except that it does not flatten given arrays before appending them.
249
275
250
-
**Argument type:** JSON_STRING, List<STRING>
276
+
**Argument type:**
277
+
-\<json_string\> must be a JSON_STRING.
278
+
-\<path\> must be a STRING.
279
+
-\<value\> can be a JSON_STRING.
251
280
252
281
**Return type:** JSON_STRING
253
282
@@ -262,28 +291,76 @@ Append adds the value to the end of the existing array with the following cases:
`json_extend(json_string, array(key1, value1, key2, value2, ...))` extends values to end of an array at path_key within the json elements. Returns the updated json object after extending.
323
+
`json_extend` is identical to `json_append` function except that it flattens given arrays before appending.
324
+
325
+
**Argument type:**
326
+
-\<json_string\> must be a JSON_STRING.
327
+
-\<path\> must be a STRING.
328
+
-\<value\> can be a JSON_STRING.
329
+
330
+
**Return type:** JSON_STRING
331
+
332
+
A string JSON object format.
333
+
334
+
**Note**
335
+
Extends adds the value to the end of the existing array with the following cases:
336
+
- path is an object value - append is ignored and the value is returned
337
+
- path is an existing array not empty - the value are added to the array's tail
338
+
- path not found - the value are added to the root of the json tree
339
+
- path is an existing array is empty - create a new array with the given value
0 commit comments