Skip to content

Instantly share code, notes, and snippets.

@lhanson
Created March 21, 2012 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lhanson/2149600 to your computer and use it in GitHub Desktop.
Save lhanson/2149600 to your computer and use it in GitHub Desktop.
clojure.data.json error
(use '[clojure.data.json :only (read-json json-str)])
(require '[clj-http.client :as client])
(def url "http://api.twitter.com/1/statuses/show/177093052035375104.json")
(read-json (client/get url))
@lhanson
Copy link
Author

lhanson commented Mar 21, 2012

This throws

IllegalArgumentException: No implementation of method: :read-json-from of protocol: #'clojure.data.json/Read-JSON-From found for class: clojure.lang.PersistentArrayMap

It turns out that client/get returns a map with cookies, headers, status, body, etc. You need to pull out the body of the response thusly:

(read-json (:body (client/get url))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment