basilisp.edn¶
EDN Encoder and Decoders
This namespace includes functions for performing basic EDN encoding from and decoding
to Basilisp builtin data structures. These decoding functions should be preferred to
basilisp.core/read-string
when reading from untrusted input sources. Unlike
basilisp.core/pr-str
, the EDN encoding functions only emit the subset of
Basilisp syntax supported by the EDN spec, so they are generally preferred to that
method.
- fn (read)[source]¶
- fn (read stream)
- fn (read stream opts)
Read the next object from the input stream. If no stream is given,
basilisp.core/*in*
is used.Several options may be specified in the map argument
opts
:- keyword
:eof
: value to return when an EOF is encountered
- keyword
:readers
: a map of tagged data readers to be used for reading data tagged elements; if none is supplied, the default-data-readers will be used (without support for the Basilisp
#py
tag)- keyword
:default
: a function of two arguments that will be called with the tag and data element if a tag is not found in
:readers
; defaultnil
- keyword
- fn (read-string s)[source]¶
- fn (read-string s opts)
Read the next object from the input string. If
nil
or the empty string, returnsnil
.
- fn (write o)[source]¶
- fn (write o writer)
Serialize the object
o
as EDN to the writer objectwriter
(which must be any file-like object supporting.write()
method).All Basilisp data structures are serializable to EDN by default. UUIDs and Instants (Python
datetime
s) are also supported by default. Support for other types may be added by extending theEDNEncodeable
protocol for that type.
- fn (write-string o)[source]¶
Serialize the object
o
as EDN and return the serialized object as a string.All Basilisp data structures are serializable to EDN by default. UUIDs and Instants (Python
datetime
s) are also supported by default. Support for other types may be added by extending theEDNEncodeable
protocol for that type.