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
0
votes
1 answer

How to print EDN output in JSON format using Cheshire custom encoder

I am newbie with Clojure and I am trying to print EDN output to valid JSON format using Cheshire custom encoder for classes defined in java. My EDN file: {:xyz #XyzBuilder "testString"} Clojure code: (defn getXyz [str] (.getXyz (XyzBuilder.)…
ppp456878
  • 155
  • 8
0
votes
1 answer

Serialize JavaScript objects in ClojureScript

How do I make a writer for JS error object to send thru the wire? When I do (pr-str (js/Error. "OOPS")) it gives me "#object[Error Error: OOPS]". And (js->clj (js/Error. "Oops!")) gives something like #object[Error Error: Oops!]. I want to make a…
user12769468
0
votes
1 answer

How can I convert EDN output to JSON which has custom readers defined

In Clojure, I am using 'generate-string' function of cheshire (https://github.com/dakrone/cheshire) library to convert EDN to JSON. It works fine for EDN without custom readers. For ex: sample.edn: {:foo "bar" :baz {:eggplant [1 2…
ppp456878
  • 155
  • 8
0
votes
1 answer

Is there a way we can re-use value of defined keys in EDN?

Is there a way I can reuse values of key defined in EDN? For ex: If I have following EDN { :abc "value1" :def :abc } When I read above EDN in Clojure, I want for 'def' key, value1 which is value of :abc to be passed. But currently :abc string…
ppp456878
  • 155
  • 8
0
votes
1 answer

In EDN, how can I pass multiple values to tagged element returned from other tagged elements

I have following EDN { :test #xyz/getXyz #abc/getAbc #fgh/getFgh "sampleString" } In Clojure, I have defined implementation for each of the tagged element which internally calls java functions. I have a requirement in which I need to pass…
ppp456878
  • 155
  • 8
0
votes
1 answer

How do I pass custom parameter to edn reader?

I following clojure code (defn reverse-reader [coll] (assert (coll? coll) "you can only reverse collections") (reverse coll) ) (def custom-readers {'demo/reverse reverse-reader}) (defn getContent [filename myCustomObject] …
ppp456878
  • 155
  • 8
0
votes
2 answers

How do I evaluate an edn/read list?

(def a (edn/read-string "(+ 1 3)")) ; => (+ 1 3) How do I evaluate this resulting list? (type (first a)) ; => cljs.core/Symbol (= (first a) '+) ; => true I suppose more generally how would I get from symbol -> function. And is this a normal…
0
votes
2 answers

How do I include a .edn file as a subset of another "parent" .edn file like the "include path" element in a .xml file?

How do I include the contents of a .edn file as a subset of another .edn file similar to the "include path" element in XML? More specifically, does the extensable data notation (EDN) have a way to "include" a file via path similar to the "include…
loudog
  • 1
  • 1
0
votes
1 answer

Run zprint-cli recursively on multiple files in nested directories via NPM scripts

Goal: Use npm scripts to run zprint-clj on each file with the appropriate file extension in a bundle of nested folders. zprint-clj expects a filename in and a filename out each time it's run. eg: zprint-clj -i -o I'm…
Squish
  • 333
  • 4
  • 17
0
votes
3 answers

Clojure - Count occurences of nested key in nested map?

I have a nested map like so: {:A {:B {:A {:B {:A {:B 0}}}}}} I want to count the occurrences of the pair [:A :B] so that in the case above, the result is 3. My initial idea was to use clojure.walk/postwalk to traverse the map and increment a…
Edmond
  • 615
  • 1
  • 5
  • 15
0
votes
2 answers

Clojure edn read auto namespaced keywords

Is there a way to instruct clojure.core.edn/read how to resolve auto namespaced keywords ? (edn/read-string "{:not-namespaced \"ko\" }") ;;=> {:not-namespaced "ko"} (edn/read-string "{:namespaced/ok \"ko\" }") ;;=> #:namespaced{:ok "ko"} …
nha
  • 17,623
  • 13
  • 87
  • 133
0
votes
1 answer

How can I convert "DD/MM/YYYY HH:MM:SS" to a clojure inst value?

Google Forms gives me this : "02/12/2014 10:44:36" What is a good way for converting it to edn time format using clojure? ;=> #inst "2014-12-02T10:44:36.000-00:00" Thank you! UPDATE: GForm is giving me hours from 0 to 23. So, the answer should…
leontalbot
  • 2,513
  • 1
  • 23
  • 32
1 2 3
4