Created
February 28, 2020 14:30
-
-
Save zmstone/ec9830818454fd88990161c728f78fad to your computer and use it in GitHub Desktop.
cli tool to unsmile a jackson smile json file
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 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