Clojure bindings for Gson, Google's JSON parsing library. See https://code.google.com/p/google-gson/ and http://www.json.org/
[com.spoon16/clj-gson "0.0.1"]
<dependency>
<groupId>com.spoon16</groupId>
<artifactId>clj-gson</artifactId>
<version>0.0.1</version>
</dependency>
=> (use '[clj-gson.json :only (to-json from-json)])
;; clojure -> json
=> (to-json {:hello [1 "two" 3] :world {"ell" "ee"}})
{
"world": {
"ell": "ee"
},
"hello": [
1,
"two",
3
]
}
;; json -> clojure
=> (from-json "{ \"hello\": [1,\"two\",3], \"world\": { \"ell\": \"ee\" } }")
{:world {:ell "ee"}, :hello [1.0 "two" 3.0]}
;; string -> json tree
=> (parse-json-tree "{ \"hello\": [1,\"two\",3], \"world\": { \"ell\": \"ee\" } }")
#<JsonObject {"hello":[1,"two",3],"world":{"ell":"ee"}}>
;; clojure -> json tree
=> (to-json-tree {:hello [1 "two" 3] :world {"ell" "ee"}})
#<JsonObject {"world":{"ell":"ee"},"hello":[1,"two",3]}>
TODO
Copyright © 2012 Eric Schoonover
Distributed under the Eclipse Public License, the same as Clojure.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close