Greg Slepak avatar Greg Slepak committed e9e2f50

json fix

Comments (0)

Files changed (2)

+Version 0.6.1
+
+  * now $BINARY can handle large data (compensated for a newLISP bug in 'read-buffer').
+  * added documentation for MAX_POST_LENGTH in request.lsp
+  * fix to Jeff's JSON.lsp plugin (switched to " instead of ' for strings)
+
 Version 0.6
 
   * added DF.DB and ObjNL

example-site/dragonfly-framework/plugins-inactive/artfulcode/json.lsp

 ;; @module Json
-;; @author Jeff Ober <jeffober@gmail.com>
+;; @author Jeff Ober <jeffober@gmail.com>, Greg Slepak added fix for proper JSON (" instead of ')
 ;; @version 2.0
 ;; @location http://static.artfulcode.net/newlisp/json.lsp
 ;; @package http://static.artfulcode.net/newlisp/json.qwerty
   (case (type-of lisp)
     ("boolean" (if lisp "true" "false"))
     ("quote" (lisp->json (eval lisp)))
-    ("symbol" (format "'%s'" (name lisp)))
-    ("string" (format "'%s'" (simple-escape lisp)))
+    ("symbol" (format {"%s"} (name lisp)))
+    ("string" (format {"%s"} (simple-escape lisp)))
     ("integer" (string lisp))
     ("float" (string lisp))
     ("list" (if (assoc? lisp)
                 (format "{ %s }"
                         (join (map (fn (pair)
-                                     (format "'%s': %s"
+                                     (format {"%s": %s}
                                              (if (symbol? (pair 0))
                                                  (name (pair 0))
                                                  (string (pair 0)))
     ("array" (string "[" (join (map lisp->json lisp) ", ") "]"))
     ("context" (let ((values '()))
                  (dotree (s lisp)
-                   (push (format "'%s': %s"
+                   (push (format {"%s": %s}
                                  (name s)
                                  (lisp->json (eval s)))
                          values -1))
 
 (define (simple-escape str)
   (replace {[\n\r]+} str {\n} 4)
-  (replace {'} str {\'} 4)
+  ;(replace {'} str {\'} 4)
+	(replace {"} str {\"})
   str)
 
 ;; @syntax (Json:json->lisp <str-json>)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.