Association-list utilities for web services
Association list item keys are assumed to be strings, and optimization declarations prioritize speed over safety. Take care to validate the structure of the association list prior to using this library to access specific values.
See the tests for complete examples.
Example:
(let ((params '(("qux" . 11)
("bar" . "baz")
("foo" . (("baaz" . "quux")
("quux" . (("foo" . "bar")))
("bar" . 33)
("foobar" . (1 2 3)))))))
(let ((qux (get-param params "qux"))
(multiple-toplevel (collect-params params '("qux" "bar")))
(baaz (get-nested-param params '("foo" "baaz")))
(multiple-nested (collect-nested-params params '(("qux")
("bar")
("foo" "baaz")
("foo" "bar")
("foo" "quux" "foo")))))
(format t "qux: ~A~%" qux)
(format t "multiple-toplevel: ~{~A~^, ~}~%" multiple-toplevel)
(format t "baaz: ~A~%" baaz)
(format t "multiple-nested: ~{~A~^, ~}~%" multiple-nested)))
;; prints:
;;
;; qux: 11
;; multiple-toplevel: 11, baz
;; baaz: quux
;; multiple-nested: 11, baz, quux, 33, bar
Not in Quicklisp, so clone to "local-projects/".
Run tests:
(asdf:test-system :foo.lisp.params)
- John Newton (jnewton@lisplizards.dev)
Copyright (c) 2024 John Newton
Apache-2.0