EDN (Extensible Data Notation) is a restricted, extensible form of Clojure syntax for transporting data and loading it safely. Use clojure.edn/read for a PushbackReader or clojure.edn/read-string for a string. section 17.0 section 17.6
EDN differs from the general Clojure reader in several deliberate ways:
- Rejects specialized reader macros such as dereferencing (@), anonymous functions, read-eval, syntax quote, and reader conditionals. section 17.6
- Ignores :read-cond and :features because reader conditionals are unsupported. section 17.6
- Accepts :readers, a map from tagged-literal names to implementations; supplied implementations override defaults. section 17.6
- Accepts :default, which handles tagged literals missing from the default reader tables. section 17.6
Reading ordinary and tagged data
(require '[clojure.edn :as edn]) (edn/read-string "[1 2 3]") ;; [1 2 3] (edn/read-string {:readers {'point identity}} "#point [1 2]") ;; [1 2] (edn/read-string {:default #(format "[Tag '%s', Value %s]" %1 %2)} "#line [[1 2] [3 4]]") ;; "[Tag 'line', Value [[1 2] [3 4]]]" section 17.6
(require '[clojure.edn :as edn]) ; #1 (alias 'core 'clojure.core) (core/read-string "@#'+") ; #2 ;; (clojure.core/deref (var +)) (edn/read-string "@#'+") ; #3 ;; RuntimeException Invalid leading character: @
Compare the general Clojure reader with EDN using a dereferencing expression: the former reads it, while EDN rejects the leading @. section 17.6
