Skip to content
Browse files

Remove Cheshire as a dependency

This removes the {:as :json} output coercion, but it can easily be
worked around by decoding the JSON yourself
  • Loading branch information...
1 parent 6acf132 commit 15ac50bc8b50648887fbf5006a9e88a1dfe7cbd4 @dakrone dakrone committed
Showing with 4 additions and 21 deletions.
  1. +3 −6 project.clj
  2. +1 −15 src/clj_http/client.clj
View
9 project.clj
@@ -6,18 +6,15 @@
:dependencies [[org.clojure/clojure "1.3.0"]
[slingshot "0.10.1"]
[commons-codec "1.5"]
- [commons-io "2.1"]
- [cheshire "2.1.0"]]
+ [commons-io "2.1"]]
:multi-deps {"1.2.1" [[org.clojure/clojure "1.2.1"]
[slingshot "0.10.1"]
[commons-codec "1.5"]
- [commons-io "2.1"]
- [cheshire "2.1.0"]]
+ [commons-io "2.1"]]
"1.4.0" [[org.clojure/clojure "1.4.0-beta1"]
[slingshot "0.10.1"]
[commons-codec "1.5"]
- [commons-io "2.1"]
- [cheshire "2.1.0"]]}
+ [commons-io "2.1"]]}
:dev-dependencies [[ring/ring-jetty-adapter "1.0.2"]
[ring/ring-devel "1.0.2"]
[lein-multi "1.1.0"]]
View
16 src/clj_http/client.clj
@@ -2,7 +2,6 @@
"Batteries-included HTTP client."
(:use [slingshot.slingshot :only [throw+]])
(:require [clojure.string :as str]
- [cheshire.core :as json]
[clj-http.core :as core]
[clj-http.util :as util])
(:import (java.io InputStream File)
@@ -75,14 +74,7 @@
(condp = as
;; Don't do anything when it's a byte-array
:byte-array resp
- ;; Convert to json from UTF-8 string
- :json
- (assoc resp :body (json/decode (String. #^"[B" body "UTF-8") true))
- ;; Convert to json with strings as keys
- :json-string-keys
- (assoc resp :body (json/decode (String. #^"[B" body "UTF-8")))
- ;; Attempt to automatically coerce the body, returning a
- ;; string if no coercions are found
+ ;; Automatically determine response type
:auto
(assoc resp
:body
@@ -94,12 +86,6 @@
(String. #^"[B" body ^String charset)
(String. #^"[B" body "UTF-8"))
- (.startsWith (str typestring) "application/json")
- (if-let [charset (second (re-find #"charset=(.*)"
- (str typestring)))]
- (json/decode (String. #^"[B" body ^String charset) true)
- (json/decode (String. #^"[B" body "UTF-8") true))
-
:else
(String. #^"[B" body "UTF-8"))))
;; No :as matches found

0 comments on commit 15ac50b

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