Liking cljdoc? Tell your friends :D

jj.bettong.edn

Reading and updating values inside EDN files.

Edits are spliced into the file's text, so comments, key order and hand formatting survive - see jj.bettong.impl.edn-text. Pass {:preserve-formatting? false} to rewrite the file from its data instead, which is pretty-printed and loses comments.

Reading and updating values inside EDN files.

Edits are spliced into the file's text, so comments, key order and hand
formatting survive - see `jj.bettong.impl.edn-text`. Pass
{:preserve-formatting? false} to rewrite the file from its data instead,
which is pretty-printed and loses comments.
raw docstring

delete-ednclj

(delete-edn opts {:keys [path key_path]})

delete-in-file!clj

(delete-in-file! file path)
(delete-in-file! file
                 path
                 {:keys [preserve-formatting?] :or {preserve-formatting? true}})

Removes the key at path, leaving the formatting around it alone. Returns the file's new data.

Removes the key at `path`, leaving the formatting around it alone.
Returns the file's new data.
raw docstring

get-in-fileclj

(get-in-file file path)

The value at path, or nil. An empty path returns the whole file.

The value at `path`, or nil. An empty path returns the whole file.
raw docstring

parse-keyclj

(parse-key k)

A path element arrives as text. It is read as EDN, so ":server" is the keyword :server, "0" is the index 0, and ""name"" is the string "name". Anything unreadable is kept as a plain string key.

A path element arrives as text. It is read as EDN, so ":server" is the
keyword :server, "0" is the index 0, and "\"name\"" is the string
"name". Anything unreadable is kept as a plain string key.
raw docstring

parse-pathclj

(parse-path path)

parse-valueclj

(parse-value value)

The new value, read as EDN so it can be any shape - a number, a string, a keyword, a map, a vector.

The new value, read as EDN so it can be any shape - a number, a string, a
keyword, a map, a vector.
raw docstring

read-ednclj

(read-edn opts {:keys [path key_path]})

read-fileclj

(read-file file)

The file's data.

The file's data.
raw docstring

set-ednclj

(set-edn opts {:keys [path key_path value]})

set-in-file!clj

(set-in-file! file path value)
(set-in-file! file
              path
              value
              {:keys [preserve-formatting?] :or {preserve-formatting? true}})

Sets path to value, creating intermediate maps as needed. Returns the file's new data.

The edit is spliced into the file's text, so everything around it - comments included - is left exactly as it was. With {:preserve-formatting? false} the file is rewritten from its data and pretty-printed instead.

Sets `path` to `value`, creating intermediate maps as needed.
Returns the file's new data.

The edit is spliced into the file's text, so everything around it - comments
included - is left exactly as it was. With {:preserve-formatting? false} the
file is rewritten from its data and pretty-printed instead.
raw docstring

update-in-file!clj

(update-in-file! file path f & args)

Applies f to the value at path - the Clojure-side counterpart to set-in-file!, for when the new value depends on the old one.

(update-in-file! "config.edn" [:server :port] inc)

Applies `f` to the value at `path` - the Clojure-side counterpart to
set-in-file!, for when the new value depends on the old one.

  (update-in-file! "config.edn" [:server :port] inc)
raw docstring

write-file!clj

(write-file! file data)

Writes data back, pretty-printed so the file stays readable.

Writes `data` back, pretty-printed so the file stays readable.
raw docstring

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