Add list->json-array
This commit is contained in:
parent
df79bc198e
commit
62cf3ff7cb
1 changed files with 12 additions and 1 deletions
|
|
@ -39,6 +39,7 @@
|
|||
render-static-asset
|
||||
render-html
|
||||
scm-alist->streaming-json
|
||||
list->json-array
|
||||
render-json
|
||||
render-text
|
||||
not-found
|
||||
|
|
@ -160,7 +161,7 @@
|
|||
(lambda (port)
|
||||
(sxml->html sxml port)))))))
|
||||
|
||||
(define* (scm-alist->streaming-json alist port #:key unicode)
|
||||
(define* (scm-alist->streaming-json alist port #:key (unicode #t))
|
||||
(put-string port "{")
|
||||
(pair-for-each
|
||||
(lambda (pair)
|
||||
|
|
@ -179,6 +180,16 @@
|
|||
alist)
|
||||
(put-string port "}"))
|
||||
|
||||
(define* (list->json-array proc list port #:key (unicode #t))
|
||||
(put-string port "[")
|
||||
(pair-for-each
|
||||
(lambda (pair)
|
||||
(scm->json (proc (car pair)) port #:unicode unicode)
|
||||
(unless (null? (cdr pair))
|
||||
(put-string port ",")))
|
||||
list)
|
||||
(put-string port "]"))
|
||||
|
||||
(define* (render-json json #:key (extra-headers '())
|
||||
(code 200)
|
||||
stream?)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue