From ce4838b58104b589894081b6c5cbd52554cf87a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Sun, 19 Feb 2023 23:41:00 -0300 Subject: Add todo.txt --- json.lisp | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 json.lisp (limited to 'json.lisp') diff --git a/json.lisp b/json.lisp new file mode 100644 index 0000000..8bb93e7 --- /dev/null +++ b/json.lisp @@ -0,0 +1,10 @@ +(in-package #:json) + +(defmacro obj (&rest fields) + (let ((o (gensym)) + (f (gensym))) + (setf fields (mapcar (lambda (x) (cons 'list x)) fields)) + `(let ((,o (make-hash-table :test #'equal :size ,(length fields)))) + (dolist (,f ,(cons 'list fields)) + (setf (gethash (car ,f) ,o) (cadr ,f))) + ,o))) -- cgit v1.2.3