[cl-json-devel] Contrib: simplified camel case

Leslie P. Polzer sky at viridian-project.de
Wed Aug 5 08:08:53 UTC 2009


You might want to include this in camel-case.lisp or
contrib. It's barely tested so far though.

(defun simplified-camel-case-to-lisp (camel-string)
  "We don't want + and * all over the place."
  (declare (string camel-string))
  (let ((*print-pretty* nil))
    (with-output-to-string (result)
      (loop for c across camel-string
            with last-was-lowercase
            when (and last-was-lowercase
                      (upper-case-p c))
              do (princ "-" result)
            if (lower-case-p c)
              do (setf last-was-lowercase t)
            else
              do (setf last-was-lowercase nil)
            do (princ (char-upcase c) result)))))

  Leslie

-- 
http://www.linkedin.com/in/polzer





More information about the cl-json-devel mailing list