Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Clojure bindings for Gson, Google's JSON parsing library.
Clojure Java
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
.gitignore
.travis.yml
README.md
example.gson-config.clj
project.clj

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.

Something went wrong with that request. Please try again.