It's been a while since I've written Clojure, so I am rusty.
Basically, I'm trying to write code which does an HTTP GET on a REST API and converts that JSON array of objects into clojure data (list of Maps?). The JSON data looks like this:
[
{
"id": 1,
"category": "technical",
"asin": "0131103628",
"title": "C Programming Language, 2nd Edition",
"publication_date": "1988-04-01T00:00:00Z",
"review": "The C book.",
"created_at": "2020-03-06T20:48:00Z"
},
{
"id": 2,
"category": "technical",
"asin": "0387966080",
"title": "The Science of Fractal Images",
"publication_date": "1988-07-19T00:00:00Z",
"review": "The book on fractal algorithms. Sadly, no longer in print. I had to search high and low for a used copied.",
"created_at": "2020-03-06T20:48:00Z"
},
// etc..
]
I'm using http-kit (I've also tried clj-http) to call the REST API and return the body. Later, I try converting the body to Clojure data. I've tried using both org.clojure/data.json and cheshire. However, I don't belive the data is being converted correctly.
(defn get-books-body
[]
(:body @(client/get books-url api-options)))
(defn get-books
[]
(parse-string get-books-body true))
When I try to display the type of the body, it shows up as an address instead of a string:
clojure-json-test.core=> (type get-books-body)
clojure_json_test.core$get_books_body
And I cannot look at the first record, after converting from JSON:
clojure-json-test.core=> (first get-books)
Execution error (IllegalArgumentException) at clojure-json-test.core/eval3169 (form- init15378865171954877190.clj:1).
Don't know how to create ISeq from: clojure_json_test.core$get_books
Any idea what I am doing wrong?