Clojure bindings for Gson, Google's JSON parsing library.
Clojure Java
Latest commit ff510d6 Sep 4, 2012 Eric Schoonover introduced custom deserializer for DynamicObject instances
- added to support using Gson TypeAdapters to write map keys
- if :force-serialize-map-keys-with-gson flag is not enabled in
  configuration then default Gson TypeAdapter will be used
- allows Named objects like keywords to be serialized as
  would be expected (without : prefix) without enabling
  complex map key serization in the Gson configuration
- provides the foundation for doing more complex deserialization
  behavior

README.md

clj-gson

Build Status

Clojure bindings for Gson, Google's JSON parsing library. See https://code.google.com/p/google-gson/ and http://www.json.org/

Dependency Information

clj-gson has been published to Clojars.org

Leiningen

[com.spoon16/clj-gson "0.0.1"]

Maven:

<dependency>
  <groupId>com.spoon16</groupId>
  <artifactId>clj-gson</artifactId>
  <version>0.0.1</version>
</dependency>

Usage

Basics

=> (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]}>

GSON Configuration

TODO

License

Copyright © 2012 Eric Schoonover

Distributed under the Eclipse Public License, the same as Clojure.