anchor.diff:  (defmethod encode ((object integer) &optional (stream *standard-output*))
     (princ object stream))
   
  +(defmacro with-aggregate/object ((stream opening-char closing-char) &body body)
  +  "Set up serialization context for aggregate serialization with the
  +  object encoder."
  +  (alexandria:with-gensyms (printed)
  +    `(progn
  +       (write-delimiter ,opening-char ,stream)
  +       (change-indentation ,stream #'+)
  +       (prog1
  +           (let (,printed)
  +             (macrolet ((with-element-output (() &body body)
  +                          `(progn
  +                             (cond
  +                               (,',printed
  +                                (write-delimiter #\, ,',stream))
  +                               (t
  +                                (setf ,',printed t)))
  +                             (write-indentation ,',stream)
  +                             ,@body)))
  +               ,@body))
  +         (change-indentation ,stream #'-)
  +         (write-indentation ,stream)
  +         (write-delimiter ,closing-char ,stream)))))
  +
   (defun encode-key/value (key value stream)
     (encode key stream)
     (write-char #\: stream)
     (encode value stream))
   
   (defmethod encode ((object hash-table) &optional (stream *standard-output*))
  -  (write-char #\{ stream)
  -  (let (printed)
  +  (with-aggregate/object (stream #\{ #\})
       (maphash (lambda (key value)
  -               (if printed
  -                   (write-char #\, stream)
  -                   (setf printed t))
  -               (encode-key/value key value stream))
  -             object))
  -  (write-char #\} stream)
  -  object)
  -
  +               (with-element-output ()
  +                 (encode-key/value key value stream)))
  +             object)
  +    object))
  +                 
   (defmethod encode ((object vector) &optional (stream *standard-output*))
  -  (write-char #\[ stream)
  -  (let (printed)
  -    (loop
  -      for value across object
  -      do (when printed
  -           (write-char #\, stream))
  -         (setf printed t)
  -         (encode value stream)))
  -  (write-char #\] stream)
  -  object)
  +  (with-aggregate/object (stream #\[ #\])
  +    (loop for value across object
  +          do (with-element-output ()
  +               (encode value stream)))
  +    object))
   
   (defmethod encode ((object list) &optional (stream *standard-output*))
  -  (write-char #\[ stream)
  -  (let (printed)
  +  (with-aggregate/object (stream #\[ #\])
       (dolist (value object)
  -      (if printed
  -          (write-char #\, stream)
  -          (setf printed t))
  -      (encode value stream)))
  -  (write-char #\] stream)
  -  object)
  +      (with-element-output ()
  +        (encode value stream)))
  +    object))
   
   (defun encode-symbol/value (symbol value stream)
     (let ((string (symbol-name symbol)))
       (encode-key/value string value stream)))
   
   (defun encode-alist (object &optional (stream *standard-output*))
  -  (loop initially (write-char #\{ stream)
  -        with printed = nil
  -        for (key . value) in object
  -        do (if printed
  -               (write-char #\, stream)
  -               (setf printed t))
  -           (encode-symbol/value key value stream)
  -        finally (write-char #\} stream)
  -                (return object)))
  +  (with-aggregate/object (stream #\{ #\})
  +    (loop for (key . value) in object
  +          do (with-element-output ()
  +               (encode-symbol/value key value stream)))
  +    object))
   
   (defun encode-plist (object &optional (stream *standard-output*))
  -  (loop initially (write-char #\{ stream)
  -        with printed = nil
  -        for (key value . rest) on object by #'cddr
  -        do (if printed
  -               (write-char #\, stream)
  -               (setf printed t))
  -           (encode-symbol/value key value stream)
  -        finally (write-char #\} stream)
  -                (return object)))
  +  (with-aggregate/object (stream #\{ #\})
  +    (loop for (key value) on object by #'cddr
  +          do (with-element-output ()
  +               (encode-symbol/value key value stream)))
  +    object))
   
   (defmethod encode ((object (eql 'true)) &optional (stream *standard-output*))
     (write-string "true" stream)
  
positive.code:   object structures."
    `(progn
       (next-aggregate-element)
       (encode ,key (output-stream *json-output*))
       (setf (car (stack *json-output*)) #\:)
       (unwind-protect
  
negative.code: (in-package :yason)
  
  (defvar *json-output*)
  
  (defparameter *default-indent* nil
    "Set to T or an numeric indentation width in order to have YASON
    indent its output by default.")
  
  (defparameter *default-indent-width* 2
    "Default indentation width for output if indentation is selected
    with no indentation width specified.")
  
  (defgeneric encode (object &optional stream)
  
  