Last active
April 10, 2019 11:26
-
-
Save Velrok/6f38b694ac19ba1a9434c40b3e652357 to your computer and use it in GitHub Desktop.
cli to convert edn to json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env inlein | |
'{:dependencies [[org.clojure/clojure "1.10.0"] | |
[cheshire "5.8.1"]]} | |
(require '[cheshire.core :as json]) | |
(require '[clojure.edn :as edn]) | |
(defn read-edn | |
[s] | |
(try | |
(edn/read-string s) | |
(catch java.lang.RuntimeException e | |
(binding [*out* *err*] | |
(println (format "ERROR: [%S] parsing: %s" | |
(.getMessage e) | |
s))) | |
nil))) | |
(run! | |
(fn [l] | |
(if l | |
(some->> l | |
read-edn | |
json/generate-string | |
println) | |
(System/exit 0))) | |
(repeatedly read-line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment