Skip to content

Instantly share code, notes, and snippets.

@chrnybo
chrnybo / encode-plists.cl
Created February 9, 2019 14:21
Make yason:encode emit property lists
(defmethod yason:encode :around ((object list) &optional (stream *standard-output*))
"If *lists-as-plists*, encode OBJECT as plist
if object satisfies #'plistp and every key is a keyword.
Otherwise encode as list."
(if (and (boundp '*lists-as-plists*)
*lists-as-plists*
(system:plistp object)
(loop for key in object by 'cddr
always (keywordp key)))
(yason:encode-plist object stream)