(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\"}"