Skip to content
Browse files

Migrate to Cheshire

  • Loading branch information...
1 parent e4d67e1 commit b76c46ca741274212271550d7e3eca670074a05f @michaelklishin michaelklishin committed Sep 7, 2012
View
6 ChangeLog.md
@@ -1,5 +1,11 @@
## Changes between Elastisch 1.0.0-rc1 and 1.0.0-rc2
+### Cheshire For JSON Serliazation
+
+Elastisch now uses (and depends on) [Cheshire](https://github.com/dakrone/cheshire) for JSON serialization.
+[clojure.data.json](https://github.com/clojure/data.json) is no longer a dependency.
+
+
### New Function for Accessing Facet Responses
`clojurewerkz.elastisch.rest.response/facets-from` is a new convenience function that returns the facets section of a response.
View
6 project.clj
@@ -3,12 +3,12 @@
:description "Clojure ElasticSearch client"
:license {:name "Eclipse Public License"}
:dependencies [[org.clojure/clojure "1.4.0"]
- [org.clojure/data.json "0.1.2"]
+ [cheshire "4.0.2"]
[clj-http "0.5.1" :exclusions [org.clojure/clojure]]
- [clojurewerkz/support "0.6.0"]]
+ [clojurewerkz/support "0.7.0"]]
:min-lein-version "2.0.0"
:profiles {:dev {:resource-paths ["test/resources"]
- :dependencies [[clj-time "0.4.2" :exclusions [org.clojure/clojure]]]}
+ :dependencies [[clj-time "0.4.4" :exclusions [org.clojure/clojure]]]}
:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.0-master-SNAPSHOT"]]}}
:aliases {"all" ["with-profile" "dev:dev,1.3:dev,1.5"]}
View
28 src/clojurewerkz/elastisch/rest.clj
@@ -1,7 +1,7 @@
(ns clojurewerkz.elastisch.rest
(:refer-clojure :exclude [get])
- (:require [clj-http.client :as http]
- [clojure.data.json :as json])
+ (:require [clj-http.client :as http]
+ [cheshire.custom :as json])
(:use [clojure.string :only [join]]))
(defrecord ElasticSearchEndpoint
@@ -14,34 +14,28 @@
(defn post
- [^String uri &{ :keys [body] :as options }]
- (io! (json/read-json
- (:body (http/post uri (merge options {:accept :json :body (json/json-str body)}))))))
+ [^String uri &{:keys [body] :as options }]
+ (io! (json/decode (:body (http/post uri (merge options {:accept :json :body (json/encode body)}))) true)))
(defn put
- [^String uri &{ :keys [body] :as options}]
- (io! (json/read-json
- (:body (http/put uri (merge options {:accept :json :body (json/json-str body) :throw-exceptions throw-exceptions}))))))
+ [^String uri &{:keys [body] :as options}]
+ (io! (json/decode (:body (http/put uri (merge options {:accept :json :body (json/encode body) :throw-exceptions throw-exceptions}))) true)))
(defn get
([^String uri]
- (io! (json/read-json
- (:body (http/get uri {:accept :json :throw-exceptions throw-exceptions})))))
- ([^String uri &{ :as options }]
- (io! (json/read-json
- (:body (http/get uri (merge options {:accept :json :throw-exceptions throw-exceptions})))))))
+ (io! (json/decode (:body (http/get uri {:accept :json :throw-exceptions throw-exceptions})) true)))
+ ([^String uri &{:as options}]
+ (io! (json/decode (:body (http/get uri (merge options {:accept :json :throw-exceptions throw-exceptions}))) true))))
(defn head
[^String uri]
(io! (http/head uri {:accept :json :throw-exceptions throw-exceptions})))
(defn delete
([^String uri]
- (io! (json/read-json
- (:body (http/delete uri {:accept :json :throw-exceptions throw-exceptions})))))
+ (io! (json/decode (:body (http/delete uri {:accept :json :throw-exceptions throw-exceptions})) true)))
([^String uri &{:keys [body] :as options}]
- (io! (json/read-json
- (:body (http/delete uri (merge options {:accept :json :body (json/json-str body) :throw-exceptions throw-exceptions})))))))
+ (io! (json/decode (:body (http/delete uri (merge options {:accept :json :body (json/encode body) :throw-exceptions throw-exceptions}))) true))))
(defn base
View
3 src/clojurewerkz/elastisch/rest/index.clj
@@ -1,7 +1,6 @@
(ns clojurewerkz.elastisch.rest.index
(:refer-clojure :exclude [flush])
- (:require [clojure.data.json :as json]
- [clojurewerkz.elastisch.rest :as rest]
+ (:require [clojurewerkz.elastisch.rest :as rest]
[clj-http.client :as http])
(:use [clojurewerkz.elastisch.rest.utils :only [join-names]]))
View
2 src/clojurewerkz/elastisch/rest/response.clj
@@ -7,7 +7,7 @@
(defn ok?
[response]
- (true? (:ok response)))
+ (true? (get response :ok)))
(defn conflict?
[response]

0 comments on commit b76c46c

Please sign in to comment.
Something went wrong with that request. Please try again.