Skip to content

Instantly share code, notes, and snippets.

@alehatsman
Created July 28, 2017 11:22
Show Gist options
  • Save alehatsman/2f634fa7f80a9f25092f1a2e4cccef2e to your computer and use it in GitHub Desktop.
Save alehatsman/2f634fa7f80a9f25092f1a2e4cccef2e to your computer and use it in GitHub Desktop.
Aleph http client get request and parse body from json to clojure map.
(require '[aleph.http :as http]
'[byte-streams :as bs]
'[cheshire.core :as cheshire]
'[manifold.deferred :as d])
(defn input-stream-to-buffered-reader [is]
(new BufferedReader (new InputStreamReader is)))
(defn parse-json-input-stream [is]
(-> (input-stream-to-buffered-reader is)
(cheshire/parse-stream)))
(d/chain (http/get "https://api.json")
:body
parse-json-input-stream)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment