That being said, I see the benefits in moving to namespace qualified keys. Currently, I'm returning structures directly in Compojure handlers, and the JSON conversion is implicitly handled. I checked Cheshire and didn't immediately see a way to generate namespaced keys. What's the best way to do this?
(ns chtst.core
(:require [cheshire.core :refer [parse-string]]
[clojure.pprint :refer [pprint]])
(:gen-class))
(def fields { "name" ::name, "age" ::age})
(defn -main
[& args]
(let [example (parse-string "{\"name\":\"fred\", \"age\":29}" fields)]
(pprint example)))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/hfSq0gaeFAc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
> However this doesn't produce good results if your JSON contains a key you haven't listed in fields –
> so you'd probably have to write an actual function to do the mapping.
(def my-ns *ns*) ; bind at compile time
;; or use a constant string for the ns if you want
(defn fields [k] (keyword (str my-ns) k))
(fields “name”)
;;=> :chtst.core/name
Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.