diff --git a/library.dylan b/library.dylan index 52c0d26..9c0bb7d 100644 --- a/library.dylan +++ b/library.dylan @@ -23,7 +23,7 @@ define module serialization // This is only for use by the other modules in this // library. - export , stream; + export , stream, ; end module; define module json-serialization diff --git a/serializer.dylan b/serializer.dylan index 1c4bc38..d5a82d2 100644 --- a/serializer.dylan +++ b/serializer.dylan @@ -63,6 +63,29 @@ define method write-object (serializer :: , object :: ) write-end-array(serializer); end; +define class () + constant slot plist-list :: , + required-init-keyword: list:; +end; + +define method as (class == , x :: ) + => (res :: ) + make(, list: x) +end; + +define method write-object (serializer :: , plist :: ) + write-start-object(serializer); + for (k from 0 below plist.plist-list.size by 2, + v from 1 by 2) + write-field(serializer, plist.plist-list[k], plist.plist-list[v]); + unless (v = plist.plist-list.size) + write-separator-object(serializer); + end unless; + end for; + write-end-object(serializer); +end; + + define method write-object (serializer :: , object :: ) write-start-object(serializer); for (value keyed-by key in object,