I have another question regarding decoding JSON in Common Lisp. I settled on ST-JSON
as my tool. I am able to get a JSO
object containing the JSON data, and access all fields with st-json:getjso
. I wanted to write a macro similar in principle to destructuring-bind
that would provide local bindings to variables named after JSON fields (since then I started doubting if this is a good idea, but that's a different question). I came up with the following:
(defmacro destructure-jso (jso &body body)
(let (keys values)
(st-json:mapjso #'(lambda (key value)
(push key keys)
(push value values))
jso)
`(destructuring-bind ,keys ,values
,@body)))
But when I try to use it on a JSO
object, I get the error The value PARAMS is not of the expected type STRUCTURE.
where PARAMS
is the object. Can someone explain this to me?
Thanks.