Reputation: 3494
I'm experimenting with Clojure and Leiningen. I was successful in executing to following line in the REPL:
(print (:body (client/get "https://coinbase.com/api/v1/prices/spot_rate?currency=CAD" {:as :json}))
I created a project with lein new http
. When I run the following lines witn lein run
then the coercion to JSON doesn't work. It simply prints a correct JSON string.
(ns http.core
(:require [clj-http.client :as client])
(:use clojure.pprint))
(defn -main
[]
(print
(:body
(client/get "https://coinbase.com/api/v1/prices/spot_rate?currency=CAD" {:as :json}))
the output of the script is
{"amount":"306.89","currency":"CAD"}
Any idea what's wrong?
Upvotes: 2
Views: 644
Reputation: 3494
As it turned out there was a breaking change with clj-http version 2.0.0.
Now one has to list explicitly the optional dependencies in project.clj
.
After I added
[cheshire "5.5.0"]
to my list of dependencies the program worked as expected. Please see the documentation for the change here.
Upvotes: 4
Reputation: 2121
I don't know exactly what changed, but [clj-http "1.1.2"] has the behavior you want.
Upvotes: 1