Liking cljdoc? Tell your friends :D

com.blockether.skjema.json

JSON reader and writer - RFC 8259, no dependencies, no reflection.

read-str / read-bytes answer plain Clojure data: an object is a map with STRING keys, an array a vector, a number a Long / BigInteger / Double, a string a String, true / false a Boolean and null nil. That is the only shape skjema validates: JSON Schema property names ARE strings, so keeping the keys strings means a schema and its instance are compared without a second spelling and without a round trip.

Reading is TOTAL: every rejection is an ex-info carrying :skjema/error :json/parse with :offset, :line and :column, never a partial value and never a raw Java exception. Depth is BOUNDED (:max-depth, default 1024) because recursive descent over hostile input is otherwise a StackOverflowError - an Error is not something a caller can handle, so a document that is too deep is REJECTED like any other malformed input.

This reader exists so the library depends on nothing. It is deliberately plain: schemas are read once, at compile time, and an instance normally arrives already parsed by whatever the host uses.

JSON reader and writer - RFC 8259, no dependencies, no reflection.

`read-str` / `read-bytes` answer plain Clojure data: an object is a map with
STRING keys, an array a vector, a number a Long / BigInteger / Double, a
string a String, `true` / `false` a Boolean and `null` nil. That is the only
shape skjema validates: JSON Schema property names ARE strings, so keeping
the keys strings means a schema and its instance are compared without a
second spelling and without a round trip.

Reading is TOTAL: every rejection is an `ex-info` carrying
`:skjema/error :json/parse` with `:offset`, `:line` and `:column`, never a
partial value and never a raw Java exception. Depth is BOUNDED
(`:max-depth`, default 1024) because recursive descent over hostile input is
otherwise a StackOverflowError - an Error is not something a caller can
handle, so a document that is too deep is REJECTED like any other malformed
input.

This reader exists so the library depends on nothing. It is deliberately
plain: schemas are read once, at compile time, and an instance normally
arrives already parsed by whatever the host uses.
raw docstring

read-bytesclj

(read-bytes b)
(read-bytes b opts)

Parse a JSON document from UTF-8 BYTES. RFC 8259 requires UTF-8, so malformed encoding is REJECTED here rather than silently replaced with U+FFFD - the replacement is what turns invalid input into a document that parses.

Parse a JSON document from UTF-8 BYTES. RFC 8259 requires UTF-8, so malformed
encoding is REJECTED here rather than silently replaced with U+FFFD - the
replacement is what turns invalid input into a document that parses.
sourceraw docstring

read-strclj

(read-str s)
(read-str s opts)

Parse one JSON document out of s. Options: :max-depth.

The whole string must be ONE value: trailing content that is not whitespace is a parse error, so a truncated stream cannot look like a valid document. Duplicate object keys resolve last-one-wins, which is what every JSON parser in practice does and what the conformance suite leaves open.

Parse one JSON document out of `s`. Options: `:max-depth`.

The whole string must be ONE value: trailing content that is not whitespace
is a parse error, so a truncated stream cannot look like a valid document.
Duplicate object keys resolve last-one-wins, which is what every JSON parser
in practice does and what the conformance suite leaves open.
sourceraw docstring

write-strclj

(write-str x)

Render Clojure data as JSON text. Keywords and symbols become strings (their name), which is how a validation result written back out keeps the specification's own key spelling. A value JSON cannot express - NaN, an infinity, a ratio, a non-string object key - is refused rather than coerced, because a silent coercion is a document nobody can validate.

Render Clojure data as JSON text. Keywords and symbols become strings (their
`name`), which is how a validation result written back out keeps the
specification's own key spelling. A value JSON cannot express - NaN, an
infinity, a ratio, a non-string object key - is refused rather than coerced,
because a silent coercion is a document nobody can validate.
sourceraw 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