Convert symbols to snake case instead of just downcasing
author |
Steve Losh <steve@stevelosh.com> |
date |
Tue, 28 Jul 2020 22:48:11 -0400 |
parents |
5a32a34392a2
|
children |
b35951eca1b2
|
branches/tags |
(none) |
files |
src/main.lisp |
Changes
--- a/src/main.lisp Tue Jul 28 21:28:29 2020 -0400
+++ b/src/main.lisp Tue Jul 28 22:48:11 2020 -0400
@@ -257,10 +257,14 @@
;;;; Object Parsers -----------------------------------------------------------
+(defun lisp-case-to-snake-case (string)
+ "Convert a Lisp-cased string designator `\"FOO-BAR\"` into snake cased `\"foo_bar\"`."
+ (substitute #\_ #\- (string-downcase string)))
+
(defclass json-class (standard-class)
((slot-name-to-json-name :accessor slot-name-to-json-name
:initarg :slot-name-to-json-name
- :initform 'string-downcase)
+ :initform 'lisp-case-to-snake-case)
(unknown-slots :accessor unknown-slots
:initarg :unknown-slots
:initform :discard)