Skip to content

Instantly share code, notes, and snippets.

@zmstone
Created February 28, 2020 14:30
Show Gist options
  • Save zmstone/ec9830818454fd88990161c728f78fad to your computer and use it in GitHub Desktop.
Save zmstone/ec9830818454fd88990161c728f78fad to your computer and use it in GitHub Desktop.
cli tool to unsmile a jackson smile json file
#!/usr/bin/env lein-exec
;; this script requires clojure, lein with lein-exec plugin
;; ref: https://github.com/kumarshantanu/lein-exec
;; it accepts first one argument as the smile-format json file path
;; decodes the smile json and print the plain json to console
(use '[leiningen.exec :only (deps)])
(deps '[[cheshire "5.10.0"]])
(require '[cheshire.core :refer :all])
(defn slurp-bytes
"Slurp the bytes from a slurpable thing"
[x]
(with-open [out (java.io.ByteArrayOutputStream.)]
(clojure.java.io/copy (clojure.java.io/input-stream x) out)
(.toByteArray out)))
(println (generate-string (decode-smile (slurp-bytes (second *command-line-args*)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment