我正在试验 Clojure 和 Leiningen。我成功执行到 REPL 中的以下行:
(print (:body (client/get "https://coinbase.com/api/v1/prices/spot_rate?currency=CAD" {:as :json}))
我创建了一个项目lein new http
。当我运行以下几行时lein run
,对 JSON 的强制不起作用。它只是打印一个正确的 JSON 字符串。
(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}))
脚本的输出是
{"amount":"306.89","currency":"CAD"}
知道有什么问题吗?