Current section

Files

Jump to
clojerl src clj clojure edn.clje
Raw

src/clj/clojure/edn.clje

; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns ^{:doc "edn reading."
:author "Rich Hickey"}
clojure.edn
(:refer-clojure :exclude [read read-string]))
(defn read
"Reads the next object from stream, which must be implement
erlang.io.PushbackReader. stream defaults to the current value
of *in*.
Reads data in the edn format (subset of Clojure data):
http://edn-format.org
opts is a map that can include the following keys:
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
When not supplied, only the default-data-readers will be used.
:default - A function of two args, that will, if present and no reader is found for a tag,
be called with the tag and the value."
{:added "1.5"}
([]
(read *in*))
([stream]
(read {} stream))
([opts stream]
(clj_edn/read stream (clj->erl opts))))
(defn read-string
"Reads one object from the string s. Returns nil when s is nil or empty.
Reads data in the edn format (subset of Clojure data):
http://edn-format.org
opts is a map as per clojure.edn/read"
{:added "1.5"}
([s] (read-string {:eof nil} s))
([opts s] (when s (clj_edn/read_string s (clj->erl opts)))))