Skip to content

Instantly share code, notes, and snippets.

@jhickner
Forked from lynaghk/gist:1141054
Created September 7, 2011 03:49
Show Gist options
  • Select an option

  • Save jhickner/1199718 to your computer and use it in GitHub Desktop.

Select an option

Save jhickner/1199718 to your computer and use it in GitHub Desktop.
Clojure sequentials & maps into JavaScript arrays and objects
(defn ->js [o]
(cond
(keyword? o) (name o)
(map? o) (let [out (js-obj)]
(doseq [[k v] o]
(aset out (->js k) (->js v)))
out)
(coll? o) (apply array (map ->js o))
:else o))
@jhickner

jhickner commented Sep 7, 2011

Copy link
Copy Markdown
Author

Working on making this recursive...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment