Skip to content
Browse files

Merge remote-tracking branch 'ztellman/master'

  • Loading branch information...
2 parents 2f4f6e7 + 03aff88 commit 5ff5a3008f102a5d647743106cb911cfddff8b62 @dakrone committed Feb 18, 2013
Showing with 18 additions and 16 deletions.
  1. +18 −16 src/cheshire/generate.clj
34 src/cheshire/generate.clj
@@ -31,25 +31,26 @@
Long (.writeNumber ~jg (long ~obj))
Double (.writeNumber ~jg (double ~obj))
Float (.writeNumber ~jg (double ~obj))
- BigInteger (.writeNumber ~jg ^BigInteger ~obj)
- BigDecimal (.writeNumber ~jg ^BigDecimal ~obj)
+ BigInteger (.writeNumber ~jg ~(with-meta obj {:tag "BigInteger"}))
+ BigDecimal (.writeNumber ~jg ~(with-meta obj {:tag "BigDecimal"}))
Ratio (.writeNumber ~jg (double ~obj))
Short (.writeNumber ~jg (int ~obj))
Byte (.writeNumber ~jg (int ~obj))
- clojure.lang.BigInt (.writeNumber ~jg ^clojure.lang.BigInt
- (.toBigInteger (bigint ~obj)))
+ clojure.lang.BigInt (.writeNumber ~jg ^BigInteger
+ (.toBigInteger ^clojure.lang.BigInt (bigint ~obj)))
(fail ~obj ~jg ~e))
- `(condp instance? ~obj
- Integer (.writeNumber ~jg (int ~obj))
- Long (.writeNumber ~jg (long ~obj))
- Double (.writeNumber ~jg (double ~obj))
- Float (.writeNumber ~jg (float ~obj))
- BigInteger (.writeNumber ~jg ^BigInteger ~obj)
- BigDecimal (.writeNumber ~jg ^BigDecimal ~obj)
- Ratio (.writeNumber ~jg (double ~obj))
- Short (.writeNumber ~jg (int ~obj))
- Byte (.writeNumber ~jg (int ~obj))
- (fail ~obj ~jg ~e))))
+ `(let [^JsonGenerator jg# ~jg]
+ (condp instance? ~obj
+ Integer (.writeNumber jg# (int ~obj))
+ Long (.writeNumber jg# (long ~obj))
+ Double (.writeNumber jg# (double ~obj))
+ Float (.writeNumber jg# (float ~obj))
+ BigInteger (.writeNumber jg# ^BigInteger ~obj)
+ BigDecimal (.writeNumber jg# ^BigDecimal ~obj)
+ Ratio (.writeNumber jg# (double ~obj))
+ Short (.writeNumber jg# (int ~obj))
+ Byte (.writeNumber jg# (int ~obj))
+ (fail ~obj jg# ~e)))))
(declare generate)
@@ -117,7 +118,8 @@
(write-string ^JsonGenerator jg (.format sdf obj)))
:else (try
(.writeNumber ^JsonGenerator jg obj)
- (catch Exception e (fail obj jg ex)))))
+ (catch Exception e
+ (fail obj jg ex)))))
;; Generic encoders, these can be used by someone writing a custom
;; encoder if so desired, after transforming an arbitrary data

0 comments on commit 5ff5a30

Please sign in to comment.
Something went wrong with that request. Please try again.