<< Back to previous view

[CLJ-1156] clojure.walk/stringifiy-keys does not stringify non-keyword keys Created: 03/Feb/13  Updated: 01/Mar/13  Resolved: 04/Feb/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Joel Kuiper Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


The doc says "Recursively transforms all map keys from keywords to strings." however only those keys that pass keyword? get transformed to string. This leaves other keys such as java.Long as-is.

A simple fix would be

(defn stringify-keys*
"Recursively transforms all map keys from keywords to strings."
(let [f (fn [[k v]] (if (keyword? k) [(name k) v] [(str k) v]))]
;; only apply to maps
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))

Comment by Andy Fingerhut [ 03/Feb/13 11:20 PM ]

It appears from the doc string that this function does exactly what it claims it will do, without any changes.

Comment by Joel Kuiper [ 04/Feb/13 4:29 AM ]

You're right.
Somehow I parsed the doc string wrongly. My sincere apologies! Can be marked invalid.

Comment by Andy Fingerhut [ 04/Feb/13 9:30 AM ]

Closing as declined, since submitter agrees that code behavior and documentation match.

Generated at Wed Oct 18 13:34:12 CDT 2017 using JIRA 4.4#649-r158309.