Add ref
author |
Steve Losh <steve@stevelosh.com> |
date |
Wed, 14 Nov 2018 18:42:31 -0500 |
parents |
70497b31cb24 |
children |
(none) |
(in-package :cacl)
(defun decode-json% (string)
(let ((yason:*parse-json-booleans-as-symbols* t)
(yason:*parse-json-arrays-as-vectors* t))
(yason:parse string)))
(defun encode-json% (json &key indent)
(with-output-to-string (s)
(yason:encode json (if indent (yason:make-json-output-stream s) s))))
(define-command (decode-json dj) (string)
(etypecase string
(string (push! (decode-json% string)))))
(define-command (encode-json ej) (object)
(etypecase object
((or hash-table vector null number (member yason:true yason:false) string)
(push! (encode-json% object)))))