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.

protocolEDNEncodeable
fn (write* this writer)

Write the object this to the stream writer encoded as EDN.

Writer will be a file-like object supporting a .write() method.

fn (read)
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; default nil

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

Read the next object from the input string. If nil or the empty string, returns nil.

fn (write o)
fn (write o writer)

Serialize the object o as EDN to the writer object writer (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 the EDNEncodeable protocol for that type.

fn (write-string o)

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 the EDNEncodeable protocol for that type.