# HG changeset patch # User Steve Losh # Date 1715136612 14400 # Node ID 06299969c9038d50008da6f294cb1c7e6a824271 # Parent 96b886c42e6899f0c64904cfeebe899b3147b451 Allow slot-name-to-json-name to return a symbol too diff -r 96b886c42e68 -r 06299969c903 src/mop.lisp --- a/src/mop.lisp Thu Aug 25 23:10:20 2022 -0400 +++ b/src/mop.lisp Tue May 07 22:50:12 2024 -0400 @@ -126,6 +126,11 @@ `(multiple-value-bind (,result ,found) ,form (if ,found ,result ,default)))) +(defun ensure-string (value) + (etypecase value + (string value) + (symbol (symbol-name value)))) + (defun coalesce-most-specific-value (dslots slot-name) "Coalesce the most-specific value of `slot-name` from the JSON direct slots. @@ -152,7 +157,7 @@ (eslot (call-next-method)) (dslots (remove-if-not #'json-direct-slot-p direct-slots))) (setf (json-name eslot) (found-or (coalesce-most-specific-value dslots 'json-name) - (funcall (slot-name-to-json-name class) name)) + (ensure-string (funcall (slot-name-to-json-name class) name))) (json-class eslot) (canonicalize-class-designator (found-or (coalesce-most-specific-value dslots 'json-class) t)) (json-initarg eslot) (first (c2mop:slot-definition-initargs eslot))