Skip to main content

transit

Jump to function (2)

transit/read-string#

(read-string s)
(read-string s opts)

Reads one Transit+JSON-Verbose value from string s.

Options: :handlers map of tag-string to 1-arg fn for ~#tag extensions :default-handler 2-arg fn (fn [tag rep] ...) invoked for any unknown tag (both scalar and array forms). Receives the bare tag name (e.g. "point", ":", "~") and the already-decoded representation.

Example:

(read-string "[\"~:foo\", 1]") ; => [:foo 1]
(read-string "[\"~#point\", [1, 2]]" {:handlers {"point" (fn [v] v)}}) ; => [1 2]

transit/write-string#

(write-string value)

Serialises value to a Transit+JSON-Verbose string.

Example:

(write-string {:a 1}) ; => "[\"~#cmap\",[\"~:a\",1]]"