Plaster
New
List
Login
common-lisp
default
anonymous
2024.03.26 00:09:27
(defclass user () ((id :type integer :initarg :id) (name :type string :initarg :name))) (defmethod jonathan:%to-json ((user user)) (jonathan:with-object (jonathan:write-key-value "id" (slot-value user 'id)) (jonathan:write-key-value "name" (slot-value user 'name)))) (jonathan:to-json (make-instance 'user :id 1 :name "Rudolph")) => "{\"id\":1,\"name\":\"Rudolph\"}"
Raw
Annotate
Repaste
Edit