;;;; serialization.lisp (in-package :dnd.api) (defmacro with-json-object (&body pairs) (list* 'json:with-object (loop for (key val . more) on pairs by #'cddr collect `(json:write-key-value ,key ,val)))) (defmethod json:%to-json ((hero hero)) (with-slots (name experience chronicle uid equipment-table) hero (with-json-object :|name| name :|experience| experience :|chronicle| chronicle :|uid| uid :|renown| (renown hero) :|title| (hero-title hero) :|class| (hero-class hero))))