I am trying to read JSON from a REST resource using clj-http version 2.2.0 but whatever I do I get the result as a string.
While debugging, I stripped down what I'm doing to this request to a static JSON document on my webserver on https://nym.at/test.json:
{"foo":1,"bar":"baz"}
I run the following code in the REPL (client
bound to the namespace clj-http.client):
(client/get "https://nym.at/test.json" {:as :json :insecure? true})
The result I get is (pritty printed manually):
{: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}
Is my expectation wrong, that the {:as :json}
should result in clj-http parsing the response as JSON and returing it at :body
or am I doing something wrong here?