A CLI tool that reads JSON from stdin then writes it to stdout in EDN format.
➜ clojure -A:native-image
➜ echo "{\"foo\": [{\"bar\": 1.33}]}" | ./core
{:foo [{:bar 1.33}]}
;; IMPORTANT! place this file under src directory | |
(ns core | |
(:require | |
[clojure.data.json :as json] | |
[clojure.edn :as edn]) | |
(:gen-class)) | |
(defn -main [& args] | |
(if (string? (first args)) | |
(prn (json/read-str (slurp (first args)) :key-fn keyword)) | |
(prn (json/read *in* :key-fn keyword)))) |
{:deps {org.clojure/data.json {:mvn/version "0.2.6"}} | |
:aliases {:native-image | |
{:extra-deps | |
:main-opts ["-m clj.native-image core" | |
"-H:Name=json2edn"] | |
{clj.native-image | |
#_{:local/root "/path/to/clj.native-image"} | |
{:git/url "https://github.com/taylorwood/clj.native-image.git" | |
:sha "0f113d46f9f0d07e8a29545c636431ddf5360a7d" | |
:tag "v0.0.3"}}}} | |
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]} |