summaryrefslogtreecommitdiff
path: root/json.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'json.lisp')
-rw-r--r--json.lisp10
1 files changed, 10 insertions, 0 deletions
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)))