zengod
zengod

Reputation: 1174

What's the best way to parse a map in clojure when using clj.http?

I have a map like so


(client/post "http://localhost:5000" {:form-params {:new {:title "some-title" :description "some-description"}}})

In the server, I have the following:

(get-in request [:form-params "new"])

Which gives me the following:

"{:title \"some-title\", :description \"some-description\"}"

A string and not an actual map. Using the Cheshire library's parse-string gives the ": unexpected" error. How do I fix this?

Upvotes: 0

Views: 180

Answers (1)

cfrick
cfrick

Reputation: 37073

Add :content-type :application/edn to your request map, to parse EDN. Add :as :auto, :coerce :always to do the coercion automatically.

Upvotes: 1

Related Questions