Liking cljdoc? Tell your friends :D

com.yetanalytics.pathetic


apply-multi-valueclj/s

(apply-multi-value json paths values)
(apply-multi-value json paths values opts-map)

Given json, a JSONPath string paths, and a collection of JSON data value, apply value to the location given by paths in the order they are given. If the location exists, update the pre-existing value. Otherwise, create the necessary data structures needed to contain value.

For example, an array specified by [0,1] in the path, then the first and second elements of value will be applied. Returns the modified json once value or the available path seqs runs out.

The same caveats as apply-value apply here as well:

  • If only the root "$" is provided, json is overwritten in its entirety.
  • If an array index skips over any vector entries, those skipped entries will be assigned nil.
  • If a path contains a wildcard and the location up to that point does not exist or is a scalar, create a new vector.
  • If a path contains a wildcard, the location is a collection, and wildcard-append? is true, append it to the coll. In the case of maps, the key is its current size, e.g.{"2" : "foo"}`.
  • Recursive descent, array slicing, and negative array indices are disallowed (as per strict mode).

The following opts-map fields are supported:

  • :first? Apply only the first "|"-separated path.
  • :strict? Always set to true regardless of value provided.
  • :wildcard-append? Dictates if wildcard values should be appended to the end of existing seqs instead of overwriting existing values. Default false.
  • :wildcard-limit Dictates how many wildcard paths should be generated. In overwrite mode, defaults to the length of each coll. In append mode, defaults to 1.
Given `json`, a JSONPath string `paths`, and a collection of JSON data
`value`, apply `value` to the location given by `paths` in the order
they are given. If the location exists, update the pre-existing value.
Otherwise, create the necessary data structures needed to contain `value`.

For example, an array specified by `[0,1]` in the path, then the first
and second elements of `value` will be applied. Returns the modified
`json` once `value` or the available path seqs runs out.

The same caveats as `apply-value` apply here as well:
- If only the root "$" is provided, `json` is overwritten in
  its entirety.
- If an array index skips over any vector entries, those skipped
  entries will be assigned `nil`.
- If a path contains a wildcard and the location up to that
  point does not exist or is a scalar, create a new vector.
- If a path contains a wildcard, the location is a collection,
  and `wildcard-append?` is `true, append it to the coll.
  In the case of maps, the key is its current size, e.g.
  `{"2" : "foo"}`.
- Recursive descent, array slicing, and negative array indices
  are disallowed (as per strict mode).

The following `opts-map` fields are supported:
- `:first?`           Apply only the first "|"-separated path.
- `:strict?`          Always set to `true` regardless of value provided.
- `:wildcard-append?` Dictates if wildcard values should be appended to
                      the end of existing seqs instead of overwriting
                      existing values. Default `false`.
- `:wildcard-limit`   Dictates how many wildcard paths should be generated.
                      In overwrite mode, defaults to the length of each coll.
                      In append mode, defaults to `1`.
sourceraw docstring

apply-multi-value*clj/s

(apply-multi-value* json paths value)
(apply-multi-value* json paths value opts-map)

Like apply-multi-value except that the paths argument is a vector of already-parsed JSONPaths.

The following opts-map fields are supported:

  • :wildcard-append? Dictates if wildcard values should be appended to the end of existing seqs instead of overwriting existing values. Default false.
  • :wildcard-limit Dictates the max number of values to applied per coll. In overwrite mode, defaults to the length of each coll. In append mode, defaults to 1.
Like `apply-multi-value` except that the `paths` argument is a vector of
already-parsed JSONPaths.

The following `opts-map` fields are supported:
- `:wildcard-append?` Dictates if wildcard values should be appended to
                      the end of existing seqs instead of overwriting
                      existing values. Default `false`.
- `:wildcard-limit`   Dictates the max number of values to applied per coll.
                      In overwrite mode, defaults to the length of each coll.
                      In append mode, defaults to `1`.
sourceraw docstring

apply-valueclj/s

(apply-value json paths value)
(apply-value json paths value opts-map)

Given json, a JSONPath string paths, and the JSON data value, apply value to the location given by paths. If the location exists, update the pre-existing value. Otherwise, create the necessary data structures needed to contain value.

The following caveats apply:

  • If only the root "$" is provided, json is overwritten in its entirety.
  • If an array index skips over any vector entries, those skipped entries will be assigned nil.
  • If a path contains a wildcard and the location up to that point does not exist or is a scalar, create a new vector.
  • If a path contains a wildcard, the location is a collection, and wildcard-append? is true, append it to the coll. In the case of maps, the key is its current size, e.g.{"2" : "foo"}`.
  • Recursive descent, array slicing, and negative array indices are disallowed (as per strict mode).

The following opts-map fields are supported:

  • :first? Apply only the first "|"-separated path.
  • :strict? Always set to true regardless of value provided.
  • :wildcard-append? Dictates if wildcard values should be appended to the end of existing seqs instead of overwriting existing values. Default false.
  • :wildcard-limit Dictates how many wildcard paths should be generated. In overwrite mode, defaults to the length of each coll. In append mode, defaults to 1.
Given `json`, a JSONPath string `paths`, and the JSON data
`value`, apply `value` to the location given by `paths`. If
the location exists, update the pre-existing value. Otherwise,
create the necessary data structures needed to contain `value`.

The following caveats apply:
- If only the root "$" is provided, `json` is overwritten in
  its entirety.
- If an array index skips over any vector entries, those skipped
  entries will be assigned `nil`.
- If a path contains a wildcard and the location up to that
  point does not exist or is a scalar, create a new vector.
- If a path contains a wildcard, the location is a collection,
  and `wildcard-append?` is `true, append it to the coll.
  In the case of maps, the key is its current size, e.g.
  `{"2" : "foo"}`.
- Recursive descent, array slicing, and negative array indices
  are disallowed (as per strict mode).

The following `opts-map` fields are supported:
- `:first?`           Apply only the first "|"-separated path.
- `:strict?`          Always set to `true` regardless of value provided.
- `:wildcard-append?` Dictates if wildcard values should be appended to
                      the end of existing seqs instead of overwriting
                      existing values. Default `false`.
- `:wildcard-limit`   Dictates how many wildcard paths should be generated.
                      In overwrite mode, defaults to the length of each coll.
                      In append mode, defaults to `1`.
sourceraw docstring

apply-value*clj/s

(apply-value* json paths value)
(apply-value* json paths value opts-map)

Like apply-value except that the paths argument is a vector of already-parsed JSONPaths.

The following opts-map fields are supported:

  • :wildcard-append? Dictates if wildcard values should be appended to the end of existing seqs instead of overwriting existing values. Default false.
  • :wildcard-limit Dictates the max number of values to applied per coll. In overwrite mode, defaults to the length of each coll. In append mode, defaults to 1.
Like `apply-value` except that the `paths` argument is a vector of
already-parsed JSONPaths.

The following `opts-map` fields are supported:
- `:wildcard-append?` Dictates if wildcard values should be appended to
                      the end of existing seqs instead of overwriting
                      existing values. Default `false`.
- `:wildcard-limit`   Dictates the max number of values to applied per coll.
                      In overwrite mode, defaults to the length of each coll.
                      In append mode, defaults to `1`.
sourceraw docstring

exciseclj/s

(excise json paths)
(excise json paths opts-map)

Given json and a JSONPath string paths, return the JSON value with the elements at the location removed.

The following opts-map fields are supported:

  • :first? Only apply the first "|"-separated path.
  • :strict? Disallow recursive descent, array slicing, and negative array indices.
  • :prune-empty? Removes empty maps and vectors, as well as key-value pairs where values are empty, after the elements are excised. Default false.
Given `json` and a JSONPath string `paths`, return the JSON value with
the elements at the location removed.

The following `opts-map` fields are supported:
- `:first?`       Only apply the first "|"-separated path.
- `:strict?`      Disallow recursive descent, array slicing, and
                  negative array indices.
- `:prune-empty?` Removes empty maps and vectors, as well as
                  key-value pairs where values are empty, after the
                  elements are excised. Default `false`.
sourceraw docstring

excise*clj/s

(excise* json paths)
(excise* json paths opts-map)

Like excise except that the paths argument is a vector of already-parsed JSONPaths.

The following opts-map fields are supported:

  • :prune-empty? Removes empty maps and vectors, as well as key-value pairs where values are empty, after the elements are excised. Default false.
Like `excise` except that the `paths` argument is a vector of
already-parsed JSONPaths.

The following `opts-map` fields are supported:
- `:prune-empty?` Removes empty maps and vectors, as well as
                  key-value pairs where values are empty, after the
                  elements are excised. Default false.
sourceraw docstring

get-path-value-mapclj/s

(get-path-value-map json paths)
(get-path-value-map json paths opts-map)

Given json and a JSONPath string paths, return a map associating JSON paths to JSON values. Does not return duplicates.

The following opts-map fields are supported:

  • :first? Only apply the first "|"-separated path.
  • :strict? Disallow recursive descent, array slicing, and negative array indices.
  • :return-missing? Return path-value pairs where the path cannot match any location in the json The result value is returned as nil. Default false.
Given `json` and a JSONPath string `paths`, return a map associating
JSON paths to JSON values. Does not return duplicates.

The following `opts-map` fields are supported:
- `:first?`          Only apply the first "|"-separated path.
- `:strict?`         Disallow recursive descent, array slicing,
                     and negative array indices.
- `:return-missing?` Return path-value pairs where the path cannot
                     match any location in the `json` The result value
                     is returned as `nil`. Default `false`.
sourceraw docstring

get-path-value-map*clj/s

(get-path-value-map* json paths)
(get-path-value-map* json paths opts-map)

Like get-path-value-map except that the paths argument is a vector of already-parsed JSONPaths.

The following opts-map fields are supported:

  • :return-missing? Return path-value pairs where the path cannot match any location in the json The result value is returned as nil. Default false.
Like `get-path-value-map` except that the `paths` argument is a
vector of already-parsed JSONPaths.

The following `opts-map` fields are supported:
- `:return-missing?` Return path-value pairs where the path cannot
                     match any location in the `json` The result value
                     is returned as `nil`. Default `false`.
sourceraw docstring

get-pathsclj/s

(get-paths json paths)
(get-paths json paths opts-map)

Given json and a JSONPath string paths, return a vector of definite key paths. Each key path is a vector of strings (keys) or integers (array indices); non-deterministic path entries like recursive descent and wildcards are removed. If the string contains multiple JSONPaths, we return the key paths for all strings.

The following opts-map fields are supported:

  • :first? Only apply the first "|"-separated path.
  • :strict? Disallow recursive descent, array slicing, and negative array indices.
  • :return-missing? Return partial paths for paths that cannot match any location in json. Default false.
Given `json` and a JSONPath string `paths`, return a vector of
definite key paths. Each key path is a vector of strings (keys)
or integers (array indices); non-deterministic path entries like
recursive descent and wildcards are removed. If the string
contains multiple JSONPaths, we return the key paths for all
strings.

The following `opts-map` fields are supported:
- `:first?`          Only apply the first "|"-separated path.
- `:strict?`         Disallow recursive descent, array slicing, and negative
                     array indices.
- `:return-missing?` Return partial paths for paths that cannot
                     match any location in `json`. Default `false`.
sourceraw docstring

get-paths*clj/s

(get-paths* json paths)
(get-paths* json paths opts-map)

Like get-paths except that the paths argument is a vector of already-parsed JSONPaths.

The following opts-map fields are supported:

  • :return-missing? Return partial paths for paths that cannot match any location in json. Default false.
Like `get-paths` except that the `paths` argument is a vector
of already-parsed JSONPaths.

The following `opts-map` fields are supported:
- `:return-missing?` Return partial paths for paths that cannot
                     match any location in `json`. Default false.
sourceraw docstring

get-valuesclj/s

(get-values json paths)
(get-values json paths opts-map)

Given json and a JSONPath string paths, return a vector of JSON values. If the string contains multiple JSONPaths, we return the union of all these values.

The following opts-map fields are supported:

  • :first? Only apply the first "|"-separated path.
  • :strict? Disallow recursive descent, array slicing, and negative array indices.
  • :return-missing? Return values that cannot be found in json as nil. Default false.
  • :return-duplicates? Return duplicate values in the result. Default true.
Given `json` and a JSONPath string `paths`, return a vector of
JSON values. If the string contains multiple JSONPaths, we return
the union of all these values.

The following `opts-map` fields are supported:
- `:first?`             Only apply the first "|"-separated path.
- `:strict?`            Disallow recursive descent, array slicing,
                        and negative array indices.
- `:return-missing?`    Return values that cannot be found in `json`
                        as nil. Default `false`.
- `:return-duplicates?` Return duplicate values in the result.
                        Default `true`.
sourceraw docstring

get-values*clj/s

(get-values* json paths)
(get-values* json paths opts-map)

Like get-values except that the paths argument is a vector of already-parsed JSONPaths.

The following opts-map fields are supported:

  • :return-missing? Return values that cannot be found in json data as nil. Default false.
  • :return-duplicates? Return duplicate values in the result. Default true.
Like `get-values` except that the `paths` argument is a vector
of already-parsed JSONPaths.

The following `opts-map` fields are supported:
- `:return-missing?`    Return values that cannot be found in `json`
                        data as `nil`. Default `false`.
- `:return-duplicates?` Return duplicate values in the result.
                        Default `true`.
sourceraw docstring

parse-pathsclj/s

(parse-paths paths)
(parse-paths paths opts-map)

Given a JSONPath string paths, parse the string. Each parsed path is a vector of the following elements:

  • '.. Recursive descent operator
  • '* Wildcard operator
  • [...] A vector of strings (keys), integers (array indices), or maps (array slicing operations).

The following opts-map fields are supported:

  • :first? Return a singleton vector containing the first path when multiple paths are joined using "|". Default false.
  • :strict? If true, disallows recursive descent, array slicing, and negative indices. Conformant to the xAPI Profile spec. Default false.
Given a JSONPath string `paths`, parse the string. Each parsed
path is a vector of the following elements:
- `'..`     Recursive descent operator
- `'*`      Wildcard operator
- `[...]`   A vector of strings (keys), integers (array indices), or
            maps (array slicing operations).

The following `opts-map` fields are supported:
- `:first?`  Return a singleton vector containing the first path
             when multiple paths are joined using "|". Default
             `false`.
- `:strict?` If true, disallows recursive descent, array slicing,
             and negative indices. Conformant to the xAPI Profile
             spec. Default `false`.
sourceraw docstring

select-keys-atclj/s

(select-keys-at json paths)
(select-keys-at json paths opts-map)

Given json and a JSONPath string paths, return a map or vector of maps representing the key path into json. If the string contains multiple JSONPaths, we return the maps for all strings. If no value exists at the selection, return a truncated map with "{}" as the innermost possible value.

The following opts-map fields are supported:

  • :first? Returns only the map corresponding to the first "|"-separated path.
  • :strict? Disallow recursive descent, array slicing, and negative array indices.
Given `json` and a JSONPath string `paths`, return a map or
vector of maps representing the key path into `json`. If the string
contains multiple JSONPaths, we return the maps for all strings.
If no value exists at the selection, return a truncated map with
"{}" as the innermost possible value.

The following `opts-map` fields are supported:
- `:first?`  Returns only the map corresponding to the first
             "|"-separated path.
- `:strict?` Disallow recursive descent, array slicing, and negative
             array indices.
sourceraw docstring

select-keys-at*clj/s

(select-keys-at* json paths)

Like select-keys-at except that the paths argument is a vector of already-parsed JSONPaths.

Does not support an opts-map argument.

Like `select-keys-at` except that the `paths` argument is a vector
of already-parsed JSONPaths.

Does not support an `opts-map` argument.
sourceraw docstring

speculate-pathsclj/s

(speculate-paths json paths)
(speculate-paths json paths opts-map)

Given json and a JSONPath string paths, return a vector of definite key paths, just like get-paths. However, unlike get-paths, paths will be enumerated even if the corresponding value does not exist in json on that path; in other words, it speculates what paths would exist if they are applied. If the string contains multiple JSONPaths, we return the key paths for all strings.

The following opts-map fields are supported:

  • :first? Only apply the first "|"-separated path.
  • :strict? Always set to true regardless of value provided.
  • :wildcard-append? Dictates if wildcard values should be appended to the end of existing seqs instead of overwriting existing values. Default true.
  • :wildcard-limit Dictates how many wildcard paths should be generated. In overwrite mode, defaults to the length of each coll. In append mode, defaults to 1
Given `json` and a JSONPath string `paths`, return a vector of
definite key paths, just like `get-paths`. However, unlike `get-paths`,
paths will be enumerated even if the corresponding value does not exist
in `json` on that path; in other words, it speculates what paths would
exist if they are applied. If the string contains multiple JSONPaths, we
return the key paths for all strings.

The following `opts-map` fields are supported:
- `:first?`           Only apply the first "|"-separated path.
- `:strict?`          Always set to `true` regardless of value provided.
- `:wildcard-append?` Dictates if wildcard values should be appended to
                      the end of existing seqs instead of overwriting
                      existing values. Default `true`.
- `:wildcard-limit`   Dictates how many wildcard paths should be generated.
                      In overwrite mode, defaults to the length of each coll.
                      In append mode, defaults to 1
sourceraw docstring

speculate-paths*clj/s

(speculate-paths* json paths)
(speculate-paths* json paths opts-map)

Like speculate-paths, but except that the paths argument is a vector of already-parsed JSONPaths.

The following opts-map fields are supported:

  • :wildcard-append? Dictates if wildcard values should be appended to the end of existing seqs instead of overwriting existing values. Default true.
  • :wildcard-limit Dictates how many wildcard paths should be generated. In overwrite mode, defaults to the length of each coll. In append mode, defaults to 1.
Like `speculate-paths`, but except that the `paths` argument is a
vector of already-parsed JSONPaths.

The following `opts-map` fields are supported:
- `:wildcard-append?` Dictates if wildcard values should be appended to
                      the end of existing seqs instead of overwriting
                      existing values. Default `true`.
- `:wildcard-limit`   Dictates how many wildcard paths should be generated.
                      In overwrite mode, defaults to the length of each coll.
                      In append mode, defaults to 1.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close