Questions tagged [edn]

Extensible Data Notation, edn, is a subset of Clojure's data notation intended to be used as a data exchange format.

Rationale and initial spec are located at https://github.com/edn-format/edn.

57 questions
27
votes
3 answers

Clojure & ClojureScript: clojure.core/read-string, clojure.edn/read-string and cljs.reader/read-string

I am not clear about the relationship between all these read-string functions. Well, it is clear that clojure.core/read-string can read any serialized string that is output by pr[n] or even print-dup. It is also clear that clojure.edn/read-string…
Neoasimov
  • 1,111
  • 2
  • 10
  • 17
20
votes
1 answer

What is the "Correct" way to write an EDN file in Clojure as of August 2013?

I would like to write out an EDN data file from Clojure as tagged literals. Although the clojure.edn API contains read and read-string, there are no writers. I'm familiar with the issue reported here. Based on that, it's my understanding that the pr…
mokeefe
  • 456
  • 1
  • 4
  • 8
13
votes
2 answers

How to use clojure.edn/read to get a sequence of objects in a file?

Clojure 1.5 introduced clojure.edn, which includes a read function that requires a PushbackReader. If I want to read the first five objects, I can do: (with-open [infile (java.io.PushbackReader. (clojure.java.io/reader "foo.txt"))] (binding [*in*…
ToBeReplaced
  • 3,334
  • 2
  • 26
  • 42
9
votes
1 answer

Is there some sort of canonical edn response we can use for ring?

I've been reading the edn spec and want to integrate it into my application. However, I don't know how to transfer edn requests between clojure and client. Do we put a content-type application/edn in the response header and just send the prn output…
zcaudate
  • 13,998
  • 7
  • 64
  • 124
7
votes
1 answer

Clojure RuntimeException - No reader function for tag db/id

What is happening when I get this error in Clojure? java.lang.RuntimeException: No reader function for tag db/id
Zefira
  • 4,329
  • 3
  • 25
  • 31
6
votes
2 answers

How can I use *data-readers* with edn?

I tried to follow the documentation for clojure.instant/read-instant-timestamp, which reads: clojure.instant/read-instant-timestamp To read an instant as a java.sql.Timestamp, bind *data-readers* to a map with this var as the value for the 'inst…
ToBeReplaced
  • 3,334
  • 2
  • 26
  • 42
5
votes
1 answer

Serializing and de-serializing Clojure code as EDN

I'm trying to use a standard serialization for Clojure code, one that will ignore white spaces, comments etc. I was thinking of using EDN for that. According to the what I read, the standard way to serialize s-expressions to EDN is through pr-str,…
5
votes
2 answers

How do you use maps created by the edn reader in clojurescript?

This prints :bar in Clojure as I would expect: (println (:foo (clojure.tools.reader.edn/read-string "{:foo :bar}"))) ;=> :bar But this prints nil in ClojureScript: (println (:foo (cljs.reader/read-string "{:foo :bar}"))) ;=> nil To make things…
bmaddy
  • 876
  • 9
  • 16
5
votes
3 answers

How can I pass edn to clojurescript from clojure without making ajax request (i.e. via hiccup-generated page)

I'm developing RIA with clojure and clojurescript. Backend uses hiccup to generate a resulting html, like (html5 [:head (include-js "/js/my-cljs-generated.js")] [:body ... ]) How can I pass edn(hashmap, vector, etc.) to clojurescript within the…
ndrw
  • 773
  • 7
  • 15
4
votes
1 answer

How to Convert Edn string to Json

I have to retrieve data from some site that sends back responses with edn bodies. I am trying to convert the sent back Edn to Json so I can parse it with Jsoup. I found a website that was able to do the conversion, but how do I implement something…
Rafat Mahmoud
  • 130
  • 3
  • 16
4
votes
1 answer

Generating Clojure EDN from Python with :symbols

I'm trying to use EDN to communicate between a simple Python server and an in browser app written using ClojureScript. So the server needs to generate and return chunks of EDN format for the browser. I've installed…
interstar
  • 26,048
  • 36
  • 112
  • 180
4
votes
2 answers

Client-side transform EDN to JSON (Datomic data consumed by HTML5 app)

I'm implementing basic end-to-end functionality from an HTML5 app to a Datomic database. The first port-of-call is to have the client make an AJAX call directly to the Datomic REST API (http://docs.datomic.com/rest.html). The problem that needs to…
westwell
  • 191
  • 2
  • 11
4
votes
1 answer

write large data structures as EDN to disk in clojure

What is the most idiomatic way to write a data structure to disk in Clojure, so I can read it back with edn/read? I tried the following, as recommended in the Clojure cookbook: (with-open [w (clojure.java.io/writer "data.clj")] (binding [*out* w] …
pholz
  • 684
  • 8
  • 19
3
votes
2 answers

convert Java objects to Clojure types

Hi Currently I am using java.data (https://github.com/clojure/java.data) to convert java pojos to clojure compatible types. It does not work for nested objects. For ex: class Abc { Map someMap; } Class Def { String b; } If I…
ppp456878
  • 155
  • 8
3
votes
1 answer

Clojure EDN as a Code Generation Metadata source

New to Clojure and wondering how to use it to make other languages I program in easier. One thing I would like to be able to do is use Clojure for code generation. For example, given the input from a data file (EDN format) how should I (1) walk this…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
1
2 3 4