summaryrefslogtreecommitdiff
path: root/generate.lisp
blob: 8bb93e7d70063f51489b2d5c4a9f8007e48c70be (plain)
1
2
3
4
5
6
7
8
9
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)))