aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Sierra <mail@stuartsierra.com>2009-05-14 00:29:48 +0000
committerStuart Sierra <mail@stuartsierra.com>2009-05-14 00:29:48 +0000
commit8770e63cc1277d76204490a225e451a8de3b416b (patch)
treea9e66ad07798c52fa623ddc3eb2449e8f51f885b
parentb402ee96757f99ff9c1be8daf8166bd2f4f9b4c7 (diff)
json/write.clj: escape characters in symbol names just like strings
-rw-r--r--src/clojure/contrib/json/write.clj5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/clojure/contrib/json/write.clj b/src/clojure/contrib/json/write.clj
index 77f04cf5..0ec4fc98 100644
--- a/src/clojure/contrib/json/write.clj
+++ b/src/clojure/contrib/json/write.clj
@@ -74,7 +74,7 @@ Within strings, all non-ASCII characters are hexadecimal escaped.
(defmethod print-json nil [x] (print "null"))
-(defmethod print-json ::symbol [x] (pr (name x)))
+(defmethod print-json ::symbol [x] (print-json (name x)))
(defmethod print-json ::array [s]
(print \[)
@@ -178,3 +178,6 @@ Within strings, all non-ASCII characters are hexadecimal escaped.
(deftest- error-on-nil-keys
(is (thrown? Exception (json-str {nil 1}))))
+
+(deftest- characters-in-symbols-are-escaped
+ (is (= "\"foo\\u1b1b\"" (json-str (symbol "foo\u1b1b"))))) \ No newline at end of file