Skip to content

Instantly share code, notes, and snippets.

@dariooddenino
dariooddenino / json.cljs
Last active October 4, 2015 10:51
Fetching JSONs and handling them in ClojureScript / Om
; A modified group-by for jsons.
; Eg. [{:id "id1" :title "one"} {:id "id2" :title "two"}]
; to, for example, this: {:id1 {:id "id1 :title "one"} :id2 {:id "id2" :title "two"}}
(defn group-json
[f coll]
(persistent!
(reduce
(fn [ret x]
(let [k (keyword (f x))]