Permalink
Browse files

handle when hashmap keys are bignums

  • Loading branch information...
1 parent 5253caf commit 944a3e33596e83a0c56ed08cf981778af38aecfe @danlarkin danlarkin committed Nov 1, 2009
Showing with 5 additions and 1 deletion.
  1. +1 −1 src/org/danlarkin/json/encoder.clj
  2. +4 −0 test/test.clj
View
2 src/org/danlarkin/json/encoder.clj
@@ -75,7 +75,7 @@
#^String pad #^String current-indent #^Integer indent-size]
(let [next-indent (get-next-indent current-indent indent-size)
k (key pair)
- ke (if (integer? k) (str k) k)]
+ ke (if (number? k) (str k) k)]
(encode-helper ke writer pad current-indent indent-size)
(.append writer ":")
(encode-helper (val pair) writer pad "" indent-size next-indent)))
View
4 test/test.clj
@@ -56,6 +56,10 @@
(is (= "{\"1\":1}"
(json/encode-to-str {1 1}))))
+(deftest single-object-bignum-key
+ (is (= "{\"1.0E25\":1}"
+ (json/encode-to-str {1e25 1}))))
+
(deftest easy-number
(is (:json= 10)))

0 comments on commit 944a3e3

Please sign in to comment.