keywordize-keys

clojure.walk

  • (keywordize-keys m)
Recursively transforms all map keys from strings to keywords.

1 Example top

  • (clojure.walk/keywordize-keys {"a" 1 "b" 2}) => {:a 1 :b 2}
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/walk.clj:91 top

(defn keywordize-keys
  "Recursively transforms all map keys from strings to keywords."
  {:added "1.1"}
  [m]
  (let [f (fn [[k v]] (if (string? k) [(keyword k) v] [k v]))]
    ;; only apply to maps
    (postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))
Vars in clojure.walk/keywordize-keys:
Used in 0 other vars

Comments top

No comments for keywordize-keys. Log in to add a comment.