On Sunday, 4 December 2016 15:11:55 UTC, Jonathon McKitrick wrote: > > 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? > parse-string takes a second argument that converts from a JSON string key to whatever you want for your clojure key - see 3rd example in https://github.com/dakrone/cheshire#decoding So you could have something like: (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))) 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. Does that help? Pete -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@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+unsubscr...@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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.