Thanks for this, Andy. I see it uses postwalk and recursion for nested maps, so it will eventually blow up the stack. Probably faster than a zipper though. Also, for changing case it uses a custom split and join instead of regex, a very interesting approach.
I won't be using it directly though because it has some issues with uberwar, but I can learn from it. On Tuesday, January 6, 2015 9:45:59 PM UTC+2, Andy Fingerhut wrote: > > I have not used it, but from the docs it appears there is at least some > overlap with this library: > > https://github.com/qerub/camel-snake-kebab > > It mentions in its docs that it avoids using regex's. > > Andy > > On Tue, Jan 6, 2015 at 11:25 AM, Noam Ben-Ari <nbe...@gmail.com > <javascript:>> wrote: > >> Hi, >> >> I've written a small library (1 ns, 100 lines) to transform nested maps >> from "dash-case" keys to "camelCase" keys and back. >> >> The original use case was taking MySQL records that use camelCase field >> names and convert them to dash-case so they don't stick out like a sore >> thumb in my code. Similarly, when writing new records into the DB, I wanted >> to camelize them back before passing to JDBC. >> >> It should work on an arbitrarily deep nested map without blowing the >> stack (using zipper). >> >> It is symmetric: >> >> (dasherize "clientOSVersion") >> => "client-OS-version" >> (camelize "client-OS-version") >> => "clientOSVersion" >> >> >> The library starts with defining functions that work on strings, then >> ones that work on keywords (internally calling the string ones) and later >> ones working on maps (that assume all keys are keywords and use the keyword >> functions). Lastly, the library defines protocols that will ease working >> with different types. >> >> I would love any feedback, but especially: >> - is there any off-the-shelf library for this already? >> - I found zipper and regex to be really hurting performance here, >> anything you would do differently to improve this? >> - anything about style... I'm writing Clojure for a year and didn't get >> much code reviews. >> >> the gist is here: >> >> https://gist.github.com/NoamB/6e940775dfa63c73ee9c >> >> Thanks. >> >> PS - I took the string versions of the functions from cuerdas ( >> https://github.com/funcool/cuerdas) and modified a bit, mainly to get >> the symmetry working. >> >> -- >> 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 >> <javascript:> >> 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 <javascript:> >> 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 <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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.