           (do (.append buffer (char c))
               (recur)))))))
 
+(defn- parse-integer [^String string]
+  (if (< (count string) 18)  ; definitely fits in a Long
+    (Long/valueOf string)
+    (or (try (Long/valueOf string)
+             (catch NumberFormatException e nil))
+        (bigint string))))
+
+(defn- parse-decimal [^String string]
+  (if *bigdec*
+    (bigdec string)
+    (Double/valueOf string)))
+
 (defn- parse-number [^PushbackReader stream]
   (let [buffer (StringBuilder.)
-        floating-point?
-        (loop [float? false]
-          (let [c (.read stream)]
-            (codepoint-case c
-              (\- \+ \0 \1 \2 \3 \4 \5 \6 \7 \8 \9)
-              (do (.append buffer (char c))
-                  (recur float?))
-              (\e \E \.)
-              (do (.append buffer (char c))
-                  (recur true))
-              (do (.unread stream c)
-                  float?))))]
-    (if floating-point?
-      (if *bigdec*
-        (bigdec (str buffer))
-        (Double/valueOf (str buffer)))
-      (Long/valueOf (str buffer)))))
+        decimal? (loop [decimal? false]
+                   (let [c (.read stream)]
+                     (codepoint-case c
+                       (\- \+ \0 \1 \2 \3 \4 \5 \6 \7 \8 \9)
+                       (do (.append buffer (char c))
+                           (recur decimal?))
+                       (\e \E \.)
+                       (do (.append buffer (char c))
+                           (recur true))
+                       (do (.unread stream c)
+                           decimal?))))]
+    (if decimal?
+      (parse-decimal (str buffer))
+      (parse-integer (str buffer)))))
 
 (defn- -parse
   [^PushbackReader stream eof-error? eof-value]


    :escape-slash false
        to turn of escaping / as \\/"
  [x writer & options]
  (let [{:keys [escape-unicode escape-slash]
         :or {escape-unicode true
              escape-slash true}} options]

(defn- write-json-null [x ^PrintWriter out]
  (.print out "null"))

(defn- write-json-named [x out]
  (write-json-string (name x) out))

(defn- write-json-generic [x out]
