Revision: 4084 Author: hans URL: http://bknr.net/trac/changeset/4084
Add encode-array-elementS and encode-object-elementS convenience functions.
U trunk/libraries/yason/encode.lisp U trunk/libraries/yason/package.lisp
Modified: trunk/libraries/yason/encode.lisp =================================================================== --- trunk/libraries/yason/encode.lisp 2008-11-26 21:28:07 UTC (rev 4083) +++ trunk/libraries/yason/encode.lisp 2008-11-27 09:36:39 UTC (rev 4084) @@ -176,6 +176,11 @@ (next-aggregate-element) (encode object (output-stream *json-output*)))
+(defun encode-array-elements (&rest objects) + "Encode OBJECTS, a list of JSON encodeable object, as array elements." + (dolist (object objects) + (encode-array-element object))) + (defun encode-object-element (key value) "Encode KEY and VALUE as object element to the last JSON object opened with WITH-OBJECT in the dynamic context. KEY and VALUE are @@ -187,6 +192,11 @@ (encode value (output-stream *json-output*)) value)
+(defun encode-object-elements (&rest elements) + "Encode plist ELEMENTS as object elements." + (loop for (key value) on elements by #'cddr + do (encode-object-element key value))) + (defmacro with-object-element ((key) &body body) "Open a new encoding context to encode a JSON object element. KEY is the key of the element. The value will be whatever BODY
Modified: trunk/libraries/yason/package.lisp =================================================================== --- trunk/libraries/yason/package.lisp 2008-11-26 21:28:07 UTC (rev 4083) +++ trunk/libraries/yason/package.lisp 2008-11-27 09:36:39 UTC (rev 4084) @@ -30,7 +30,9 @@ #:no-json-output-context #:with-array #:encode-array-element + #:encode-array-elements #:with-object #:encode-object-element + #:encode-object-elements #:with-object-element #:with-response))