Skip to content

Instantly share code, notes, and snippets.

@aoeuidht
Created April 17, 2013 06:50
Show Gist options
  • Save aoeuidht/5402272 to your computer and use it in GitHub Desktop.
Save aoeuidht/5402272 to your computer and use it in GitHub Desktop.
generate json files in my documentation
#! /usr/bin/sbcl --script
(load "~/quicklisp/setup.lisp")
(with-open-file (*standard-output* "/dev/null" :direction :output
:if-exists :supersede)
(ql:quickload "cl-json"))
(defmacro rep-item (item rep-cnt)
`(loop for i from 1 to ,rep-cnt collect ,item))
(let ((gossip-item '((a . liszt)(c . msg1)(ts . 123456)))
(part-item '((nick . liszt)(uid . a1b2c3d4)(loc . "(1234,5678)")
(ts . 123456)(absent . 1)))
(act-info '((url . test)(part_num . 25)(aid . a1b2c3d4e5)
(theme . act-theme)(ts_start . 12345)(ts_end . 12345))))
(let((resultset `(,@act-info
(gossip . ,(rep-item gossip-item 3))
(part_num . 10)
(participants . ,(rep-item part-item 3))
(ancestor . (,part-item)))))
(json:encode-json
`((errno . 0)(type . 620)(errmsg . ok)(result . ,resultset)))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment