Liking cljdoc? Tell your friends :D

rewrite-json.core

High-level, path-based API for format-preserving JSON/JSONC editing.

This namespace provides a simple assoc-in / get-in / update-in style interface that delegates to the zipper internally.

Usage: (require '[rewrite-json.core :as rj])

;; Round-trip preserving formatting (-> (rj/parse-string json-str) (rj/assoc-in ["name"] "new-value") rj/to-string)

;; Read a nested value (rj/get-in (rj/parse-string json-str) ["dependencies" "react"])

High-level, path-based API for format-preserving JSON/JSONC editing.

This namespace provides a simple `assoc-in` / `get-in` / `update-in`
style interface that delegates to the zipper internally.

Usage:
  (require '[rewrite-json.core :as rj])

  ;; Round-trip preserving formatting
  (-> (rj/parse-string json-str)
      (rj/assoc-in ["name"] "new-value")
      rj/to-string)

  ;; Read a nested value
  (rj/get-in (rj/parse-string json-str) ["dependencies" "react"])
raw docstring

assoc-inclj

(assoc-in root path v)

Set the value at path in the node tree. If the path exists, replaces the value node while preserving surrounding formatting. If any key along the path doesn't exist in an object, the missing intermediate keys are created as empty objects {} (matching clojure.core/assoc-in semantics). If the final key doesn't exist, a new entry is appended. v can be a Clojure value (string, number, boolean, nil, map, vector) or a node.

Returns the updated root node.

Set the value at `path` in the node tree.
If the path exists, replaces the value node while preserving surrounding
formatting. If any key along the path doesn't exist in an object, the
missing intermediate keys are created as empty objects `{}` (matching
clojure.core/assoc-in semantics). If the final key doesn't exist, a new
entry is appended.
`v` can be a Clojure value (string, number, boolean, nil, map, vector)
or a node.

Returns the updated root node.
sourceraw docstring

dissoc-inclj

(dissoc-in root path)
source

get-inclj

(get-in root path)
(get-in root path not-found)

Get the Clojure value at path in the node tree. path is a vector of string keys and/or integer indices.

Example: (get-in root ["dependencies" "react"]) (get-in root ["items" 0 "name"])

Get the Clojure value at `path` in the node tree.
`path` is a vector of string keys and/or integer indices.

Example: (get-in root ["dependencies" "react"])
         (get-in root ["items" 0 "name"])
sourceraw docstring

parse-stringclj

(parse-string s)
source

to-stringclj

(to-string root)
source

update-inclj

(update-in root path f & args)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close