Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

program to json convert

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 doc
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 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.