-
Notifications
You must be signed in to change notification settings - Fork 2
/
json.lisp
29 lines (25 loc) · 853 Bytes
/
json.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(in-package :json)
(defun write-json-chars (s stream)
"Write JSON representations (chars or escape sequences) of
characters in string S to STREAM."
(loop for ch across s
for code = (char-code ch)
with special
if (setq special (car (rassoc ch +json-lisp-escaped-chars+)))
do (write-char #\\ stream) (write-char special stream)
else
do (write-char ch stream)))
(in-package :clouchdb)
(defun write-json-chars (s stream)
(declare (inline lisp-special-char-to-json))
(loop for ch across s
for code = (char-code ch)
for special = (lisp-special-char-to-json ch)
do
(cond
((and special (not (char= special #\/)))
(write-char #\\ stream)
(write-char special stream))
;;((<= code #x1f)
;; (format stream "\\u~4,'0x" code))
(t (write-char ch stream)))))