|
Revision 4067, 0.8 kB
(checked in by hans, 3 weeks ago)
|
Make STREAM argument in json:encode method optional.
|
| Line | |
|---|
| 1 |
(in-package :bknr.datastore) |
|---|
| 2 |
|
|---|
| 3 |
(defparameter *ignore-slots* '(bknr.datastore::id bknr.indices::destroyed-p)) |
|---|
| 4 |
|
|---|
| 5 |
(defmacro with-json-ignore-slots ((&rest slots) &body body) |
|---|
| 6 |
`(let ((*ignore-slots* (append *ignore-slots* ,slots))) |
|---|
| 7 |
,@body)) |
|---|
| 8 |
|
|---|
| 9 |
(defmethod json:encode ((object store-object) &optional (stream *standard-output*)) |
|---|
| 10 |
(json:with-output (stream) |
|---|
| 11 |
(json:with-object () |
|---|
| 12 |
(dolist (slotdef (closer-mop:class-slots (class-of object))) |
|---|
| 13 |
(when (and (slot-boundp object (closer-mop:slot-definition-name slotdef)) |
|---|
| 14 |
(not (find (closer-mop:slot-definition-name slotdef) *ignore-slots*))) |
|---|
| 15 |
(json:encode-object-element (closer-mop:slot-definition-name slotdef) |
|---|
| 16 |
(slot-value object (closer-mop:slot-definition-name slotdef)))))))) |
|---|