Skip to content

Commit bdedc0f

Browse files
committed
Apply parse recursively
1 parent bb9e5fb commit bdedc0f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/client.lisp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@
6060
(loop :for (key val) :on plist :by #'cddr
6161
:collect (cons (to-camel-case (symbol-name key)) val)))
6262

63-
(defun %camel-case-hash-table->kebab-case-plist (hash-table)
64-
(loop :for (key . val) :in (hash-table-alist hash-table)
65-
:append (list (make-keyword (string-upcase (to-kebab-case key))) val)))
63+
(defun %jzon-object->kebab-case-plist (obj)
64+
(typecase obj
65+
(simple-vector (mapcar #'%jzon-object->kebab-case-plist
66+
(coerce obj 'list)))
67+
(hash-table (loop :for (key . val) :in (hash-table-alist obj)
68+
:append (list (make-keyword (string-upcase (to-kebab-case key)))
69+
(%jzon-object->kebab-case-plist val))))
70+
(t obj)))
6671

6772
(defun %build-query (query)
6873
(%kebab-case-plist->camel-case-alist query))
@@ -71,7 +76,7 @@
7176
(and content (stringify (alist-hash-table (%kebab-case-plist->camel-case-alist content)))))
7277

7378
(defun %parse-response (body)
74-
(%camel-case-hash-table->kebab-case-plist (parse body)))
79+
(%jzon-object->kebab-case-plist (parse body)))
7580

7681
(defmacro define-list-client (endpoint)
7782
(let ((str-endpoint (string-downcase (string endpoint)))

0 commit comments

Comments
 (0)