clj-commons / aleph

Asynchronous streaming communication for Clojure - web server, web client, and raw TCP/UDP
http://aleph.io
MIT License
2.54k stars 241 forks source link

Formatting response :as :json only works when Cheshire is on the classpath #544

Closed vincent-dm closed 2 years ago

vincent-dm commented 4 years ago

When fetching data from a JSON-API, I want to parse the response string as a Clojure data structure. The aleph.http/get allows me to do this by setting :as :json in the options map.

However: this only seems to work when the Cheshire library is present on the classpath, due to this code. If it isn't, the response will be returned as a string.

This behavior seems like a bug: the flag should either work or throw an exception, but not silently fail.

kachayev commented 4 years ago

Aleph mimics clj-http behavior, [here](https://github.com/dakrone/clj-http/blob/76130e65aa90df3eb9cf68a5ea5e8d8b2fb2d2e8/src/clj_http/client.clj#L24-L280.

vincent-dm commented 4 years ago

Ok, I see. It's an unfortunate design (especially the silent failing if Cheshire is missing), but if API parity with clj-http is a primary goal, I guess it's a given...