Welcome! Please see the About page for a little more info on how this works.

0 votes
in Collections by

Just learning Clojure. I have the following json string:

(def json "{\"a\": 1, \"b\": \"val\", \"c\": {\"D/E\": [1, 2, 3]}}}")

If the key-fn param is true in the Cheshire parse-string call I got the following map:

(def parsed-json (cheshire/parse-string json true))
;; ==> {:a 1, :b "val", :c #:D{:E [1 2 3]}}
(type parsed-json)
;; => clojure.lang.PersistentArrayMap
(type (:c parsed-json))
;; => clojure.lang.PersistentArrayMap

How can I access the [1 2 3] array? I don't understand what is #:D here, and how I can access :E.

(get-in {:a 1, :b "val", :c #:D{:E [1 2 3]}} [:c :D/E])

1 Answer

+3 votes
selected by
Best answer

#:D {...} is called "Map namespace syntax": https://clojure.org/reference/reader#map_namespace_syntax

#:D{:E ...} is the same as {:D/E ...}.