2016-05-16 5 views
4

clj-httpバージョン2.2.0を使用してRESTリソースからJSONを読み込もうとしていますが、結果を文字列として取得します。clj-httpがJSONを返さない

デバッグ中に、私は私がhttps://nym.at/test.jsonの私のウェブサーバ上の静的なJSON文書にこの要求にやってストリップダウン:

{"foo":1,"bar":"baz"} 

私は名前空間にバインドされたREPL(clientで次のコードを実行します。 CLJ-http.client):

{:status 200, 
:headers {"Server" "Apache/2.4.18 (Debian)", 
      "Upgrade" "h2,h2c", 
      "Content-Type" "application/json", 
      "Content-Length" "22", 
      "Strict-Transport-Security" "max-age=31536000; includeSubDomains", 
      "Connection" "Upgrade, close", 
      "Accept-Ranges" "bytes", 
      "ETag" "\"16-532fcf29f30c6\"", 
      "Date" "Mon, 16 May 2016 22:14:59 GMT", 
      "Last-Modified" "Mon, 16 May 2016 22:14:27 GMT"}, 
:body "{\"foo\":1,\"bar\":\"baz\"}\n", 
:request-time 637, 
:trace-redirects ["https://nym.at/test.json"], 
:orig-content-encoding nil} 

(client/get "https://nym.at/test.json" {:as :json :insecure? true}) 

私が得る結果は(手動印刷pritty)であります

{:as :json}は、clj-httpがJSONとしてレスポンスを解析し、:bodyにリトレースするか、ここで何か間違っていると私の予想が間違っていますか?

答えて

7

プロジェクトに[cheshire "5.6.1"]を追加し、それは魔法の

作業を開始しますが働い https://github.com/dakrone/clj-http#optional-dependencies

+0

感謝を参照してください。チェシャーは依存関係だと思っていたので、私はドキュメントを誤解しているはずです。 –

関連する問題