Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Rich Hickey richhickey
file 46 lines (38 sloc) 1.776 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (
; 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"}
  (:refer-clojure :exclude [read read-string]))

(defn read
  "Reads the next object from stream, which must be an instance of or some derivee. stream defaults to the
current value of *in*.

Reads data in the edn format (subset of Clojure data):

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*))
   (read {} stream))
  ([opts stream]
     (clojure.lang.EdnReader/read stream 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):

opts is a map as per clojure.edn/read"
  {:added "1.5"}
  ([s] (read-string {:eof nil} s))
  ([opts s] (when s (clojure.lang.EdnReader/readString s opts))))
Something went wrong with that request. Please try again.