summaryrefslogtreecommitdiff
path: root/serialization.lisp
blob: d1689c1eb0f1e02a929884499d346bade9e5855a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
;;;; 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))))