Skip to content

Commit

Permalink
update README to reflect new default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
lancepantz committed Sep 20, 2011
1 parent ad2e4ed commit 58decfb
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@ Fast JSON encoding and decoding for Clojure via the Jackson library.
## Encoding/Decoding Details

`clj-json` can generate JSON for maps, vectors, lists, keywords, strings, integers, doubles, floats, and booleans.
By default sets will be coerced into lists.

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.
Namespaced keywords will encode to the form "namespace/keyword" by default.

## Redefining Coercions

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

```clojure
(binding [clj-json.core/*coercions* {clojure.lang.IPersistentSet (fn [x] (reduce (fn [acc x] (assoc acc x true)) {} x))}]
(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/parse-string
(json/generate-string {"foo" #{"bar" "bang"}})))))
Expand Down

0 comments on commit 58decfb

Please sign in to comment.