Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2576dd1530
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (36 sloc) 1.474 kb


Fast JSON encoding and decoding for Clojure via the Jackson library.


(require '(clj-json [core :as json]))
(import '( StringReader BufferedReader))

(json/generate-string {"foo" "bar"})

(json/parse-string "{\"foo\":\"bar\"}")
{"foo" "bar"}

  (BufferedReader. (StringReader. "{\"foo\":\"bar\"}{\"biz\":\"bat\"}")))
({"foo" "bar"} {"biz" "bat"})


clj-json is available as a Maven artifact from Clojars.

Encoding/Decoding Details

clj-json can generate JSON for maps, vectors, lists, keywords, strings, integers, doubles, floats, and booleans.

Note that keywords generate as strings without a leading :, and will read via parse-string and parsed-seq as strings, however both have an optional boolean argument to keywordize the keys of maps.

Redefining Coercions

Coercions can be redefined by binding *coercions*. For example, to coerce sets into existence map:

(binding [clj-json.core/*coercions* {clojure.lang.PersistentHashSet (fn [x] (reduce (fn [acc x] (assoc acc x true)) {} x))}]
  (is (= {"foo" {"bang" true, "bar" true}}
        (json/generate-string {"foo" #{"bar" "bang"}})))))


To build, test, and package the clj-json source using Leiningen:

$ lein deps
$ lein javac
$ lein test
$ lein jar


Release under an MIT license.

Jump to Line
Something went wrong with that request. Please try again.