cognitect.transit

An implementation of the transit-format for Clojure built
on top of the transit-java library.

default-read-handlers

Returns a map of default ReadHandlers for
Clojure types. Java types are handled
by the default ReadHandlers provided by the
transit-java library.

default-write-handlers

Returns a map of default WriteHandlers for
Clojure types. Java types are handled
by the default WriteHandlers provided by the
transit-java library.

HandlerMapProvider

protocol

members

handler-map

(handler-map this)

list-builder

(list-builder)
Creates an ArrayBuilder that makes Clojure-
compatible lists.

map-builder

(map-builder)
Creates a MapBuilder that makes Clojure-
compatible maps.

nsed-name

(nsed-name kw-or-sym)
Convert a keyword or symbol to a string in
namespace/name format.

read

(read reader)
Reads a value from a reader. Throws a RuntimeException when
the reader's InputStream is empty.

read-array-handler

(read-array-handler from-rep array-reader)
Creates a Transit ArrayReadHandler whose fromRep
and arrayReader methods invoke the provided fns.

read-handler

(read-handler from-rep)
Creates a transit ReadHandler whose fromRep
method invokes the provided fn.

read-handler-map

(read-handler-map custom-handlers)
Returns a HandlerMapContainer containing a ReadHandlerMap
containing all the default handlers for Clojure and Java and any
custom handlers that you supply, letting you store the return value
and pass it to multiple invocations of reader.  This can be more
efficient than repeatedly handing the same raw map of tags -> custom
handlers to reader.

read-map-handler

(read-map-handler from-rep map-reader)
Creates a Transit MapReadHandler whose fromRep
and mapReader methods invoke the provided fns.

reader

(reader in type)(reader in type {:keys [handlers default-handler]})
Creates a reader over the provided source `in` using
the specified format, one of: :msgpack, :json or :json-verbose.

An optional opts map may be passed. Supported options are:

:handlers - a map of tags to ReadHandler instances, they are merged
with the Clojure default-read-handlers and then with the default ReadHandlers
provided by transit-java.

:default-handler - an instance of DefaultReadHandler, used to process
transit encoded values for which there is no other ReadHandler; if
:default-handler is not specified, non-readable values are returned
as TaggedValues.

record-read-handler

(record-read-handler type)
Creates a ReadHandler for a record type

record-read-handlers

(record-read-handlers & types)
Creates a map of record type tags to ReadHandlers

record-write-handler

(record-write-handler type)
Creates a WriteHandler for a record type

record-write-handlers

(record-write-handlers & types)
Creates a map of record types to WriteHandlers

tagged-value

(tagged-value tag rep)
Creates a TaggedValue object.

write

(write writer o)
Writes a value to a transit writer.

write-handler

(write-handler tag-fn rep-fn)(write-handler tag-fn rep-fn str-rep-fn)(write-handler tag-fn rep-fn str-rep-fn verbose-handler-fn)
Creates a transit WriteHandler whose tag, rep,
stringRep, and verboseWriteHandler methods
invoke the provided fns.

If a non-fn is passed as an argument, implemented
handler method returns the value unaltered.

write-handler-map

(write-handler-map custom-handlers)
Returns a HandlerMapContainer containing a WriteHandlerMap
containing all the default handlers for Clojure and Java and any
custom handlers that you supply, letting you store the return value
and pass it to multiple invocations of writer.  This can be more
efficient than repeatedly handing the same raw map of types -> custom
handlers to writer.

write-meta

(write-meta x)
For :transform. Will write any metadata present on the value.

writer

(writer out type)(writer out type {:keys [handlers default-handler transform]})
Creates a writer over the provided destination `out` using
the specified format, one of: :msgpack, :json or :json-verbose.

An optional opts map may be passed. Supported options are:

:handlers - a map of types to WriteHandler instances, they are merged
with the default-handlers and then with the default handlers
provided by transit-java.

:default-handler - a default WriteHandler to use if NO handler is
found for a type. If no default is specified, an error will be
thrown for an unknown type.

:transform - a function of one argument that will transform values before
they are written.