From fdbda3672fd7530d347575618ec4c349b9f81401 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Sat, 22 Jun 2024 13:33:05 -0500 Subject: [PATCH] Fix JSON serialization issue with double-commas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … I forgot to add an output to YASON:ENCODE! --- src/activity-vocabulary.lisp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/activity-vocabulary.lisp b/src/activity-vocabulary.lisp index 65fdf5e..9ff6641 100644 --- a/src/activity-vocabulary.lisp +++ b/src/activity-vocabulary.lisp @@ -128,7 +128,7 @@ CLASS’es slots with JSON keys based on the camel-cased slot name." This returns a function to create a quoted function that should be called for each slot, again and again, by YASON:ENCODE-SLOTS." (lambda (slot-key-pair) - `(let ((key ',(car slot-key-pair)) + `(let ((key ',(car slot-key-pair)) (value (slot-value obj ',(car slot-key-pair)))) (cond ((eq key '@context) ; Encoded in YASON:ENCODE-OBJECT using *@context* (setq *@context* (merge-@contexts *@context* value))) @@ -280,19 +280,20 @@ into one. Otherwise, parse it into an associative list." ;;; ———————————————————————————————————————— ;; Note-worthy: See the above-defined DEFINE-YASON-ENCODE-SLOTS. (defmethod yason:encode ((obj object) &optional (stream *standard-output*)) - (yason:encode-object obj)) + (yason:with-output (stream) + (yason:encode-object obj))) (defmethod yason:encode-object ((obj object)) (typecase *@context* - (null ; If this is the top-level (non-nested) object, establish a @context. + (null ; If this is the top-level (non-nested) object, establish a @context. (let ((*@context* 'top-level)) (yason:encode-object obj))) (symbol ; In the top-level, encode slots and then @context. (setq *@context* (slot-value obj '@context)) (yason:with-object () - (yason:encode-slots obj) - (yason:encode-object-element "@context" *@context*))) - (T ; In nested objects, only encode slots — not *@context*. + (yason:encode-slots obj) + (yason:encode-object-element "@context" *@context*))) + (T ; In nested objects, only encode slots — not *@context*. (yason:with-object () (yason:encode-slots obj)))))