(read reader & options)
Reads a single item of JSON data from a java.io.Reader. Options are
key-value pairs, valid options are:
:eof-error? boolean
If true (default) will throw exception if the stream is empty.
:eof-value Object
Object to return if the stream is empty and eof-error? is
false. Default is nil.
:bigdec boolean
If true use BigDecimal for decimal numbers instead of Double.
Default is false.
:key-fn function
Single-argument function called on JSON property names; return
value will replace the property names in the output. Default
is clojure.core/identity, use clojure.core/keyword to get
keyword properties.
:value-fn function
Function to transform values in maps ("objects" in JSON) in
the output. For each JSON property, value-fn is called with
two arguments: the property name (transformed by key-fn) and
the value. The return value of value-fn will replace the value
in the output. If value-fn returns itself, the property will
be omitted from the output. The default value-fn returns the
value unchanged. This option does not apply to non-map
collections.
Source
(defn read
"Reads a single item of JSON data from a java.io.Reader. Options are
key-value pairs, valid options are:
:eof-error? boolean
If true (default) will throw exception if the stream is empty.
:eof-value Object
Object to return if the stream is empty and eof-error? is
false. Default is nil.
:bigdec boolean
If true use BigDecimal for decimal numbers instead of Double.
Default is false.
:key-fn function
Single-argument function called on JSON property names; return
value will replace the property names in the output. Default
is clojure.core/identity, use clojure.core/keyword to get
keyword properties.
:value-fn function
Function to transform values in maps (\"objects\" in JSON) in
the output. For each JSON property, value-fn is called with
two arguments: the property name (transformed by key-fn) and
the value. The return value of value-fn will replace the value
in the output. If value-fn returns itself, the property will
be omitted from the output. The default value-fn returns the
value unchanged. This option does not apply to non-map
collections."
[reader & options]
(let [{:keys [eof-error? eof-value bigdec key-fn value-fn]
:or {bigdec false
eof-error? true
key-fn identity
value-fn default-value-fn}} options]
(binding [*bigdec* bigdec
*key-fn* key-fn
*value-fn* value-fn]
(-read (PushbackReader. reader) eof-error? eof-value))))