EDN is Clojure's printed form for nested data. pr-str writes it and read-string reads it back. It fills the role JSON fills in a Go program: a text form of maps, vectors, strings, and numbers. encoding/json is not in glj's default package map.
pr-str
read-string
encoding/json
glj
(def person {:name "Ada" :scores [1 2 3]}) (def text (pr-str person)) (println text) (println (= (read-string text) person))
Sets, keywords, and symbols round-trip too. Sort a set before printing it if the order matters.
(println (sort (read-string "#{:b :a}")))
Reading the printed text produces a value equal to the original map.
$ glj edn.glj {:name "Ada", :scores [1 2 3]} true (:a :b)
Next example: Time.
A hands-on tour in the style of Go by Example. Glojure is a Clojure interpreter hosted on Go.