70497b31cb24

Give the JSON commands better names
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 14 Nov 2018 18:31:39 -0500
parents bb5224a1a209
children 37133d1e538a
branches/tags (none)
files src/json.lisp

Changes

--- a/src/json.lisp	Wed Nov 14 18:18:20 2018 -0500
+++ b/src/json.lisp	Wed Nov 14 18:31:39 2018 -0500
@@ -1,21 +1,22 @@
 (in-package :cacl)
 
-(defun string-to-json (string)
+(defun decode-json% (string)
   (let ((yason:*parse-json-booleans-as-symbols* t)
         (yason:*parse-json-arrays-as-vectors* t))
     (yason:parse string)))
 
-(defun json-to-string (json &key indent)
+(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 (from-json fj) (string)
+(define-command (decode-json dj) (string)
   (etypecase string
-    (string (push! (string-to-json string)))))
+    (string (push! (decode-json% string)))))
 
-(define-command (to-json tj) (json)
-  (etypecase json
-    (json (push! (json-to-string json)))))
+(define-command (encode-json ej) (object)
+  (etypecase object
+    ((or hash-table vector null number (member yason:true yason:false) string)
+     (push! (encode-json% object)))))