Permalink
Browse files

Handle quotes in JSON keys correctly; refs #98

  • Loading branch information...
1 parent a579d18 commit d6f6ccfaeac03e35b1f9dbfa04424866cd9b2a41 @stuartsierra stuartsierra committed Nov 26, 2010
@@ -238,9 +238,7 @@
(let [[k v] (first x)]
(when (nil? k)
(throw (Exception. "JSON object keys cannot be nil/null")))
- (.print out \")
- (.print out (as-str k))
- (.print out \")
+ (write-json-string (as-str k) out)
(.print out \:)
(write-json v out))
(let [nxt (next x)]
@@ -185,6 +185,9 @@
(deftest can-accept-eof
(is (= ::eof (read-json "" true false ::eof))))
+(deftest characters-in-map-keys-are-escaped
+ (is (= (json-str {"\"" 42}) "{\"\\\"\":42}")))
+
;;; Pretty-printer
(deftest pretty-printing

0 comments on commit d6f6ccf

Please sign in to comment.