Created
March 14, 2011 16:54
-
-
Save alsor/869443 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn transform-fields [m] | |
(into [] (flatten (for [[k v] m] [k {:type (keyword v)}])))) | |
(defn parse-json-config [s] | |
(let [jsn (keywordize-keys (json/parse-string s)) | |
result (into {} (for [[idx cfg-map] jsn] | |
{idx (into {} (for [[k v] cfg-map] | |
(if (or (= :fields k) (= :attributes k)) | |
{k (transform-fields v)} | |
{k v})))}))] | |
(trace (str "config loaded and parsed from json: " result)) | |
result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment