I am trying to get JSON import in Common Lisp. I figured out how to decode an object from a JSON string, but I don't know how to access the properties of the object that's returned. To decode a string (and store the result in ***tempjson**), I do this:
(defun test-json ()
(with-input-from-string
(s "{\"foo\": [1, 2, 3], \"bar\": true, \"baz\": \"!\"}")
(defparameter *tempjson* (json:decode-json s))))
How can I access *tempjson* data. For example, how can I get the value of the foo property?
decode-json
appears to return an association list (at least in this case; see documentation). You can access the values with the functionassoc
: