Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
program to json convert
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
doc
src/bin2json
.gitignore
README.md
project.clj

README.md

(ns bin2json.core
  (:require [cheshire.core :as JSON])
  (:use [clojure.java.shell :only [sh]]))

(comment
  bin2json.core=>(println (bin2json "echo" 1 2 3))
;  {"_cmd":"echo 1 2 3",
;   "_data":{"exit":0,
;            "out":"1 2 3\n",
;            "err":""}}
  )

(defn bin2json
  [program & args]
  (let
      [args (reduce
             #(clojure.string/join " " %&)
             args)]

  (JSON/generate-string
   (hash-map :_cmd (str program " " args)
             :_data (sh program args))
   {:escape-non-ascii true})))
Something went wrong with that request. Please try again.