stringify-keys

clojure.walk

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

1 Example top

  • (use 'clojure.walk)
    
    (stringify-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:99 top

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

Comments top

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