     (name x)
     (str x)))
 
-(defn- write-json-object [m ^PrintWriter out] 
+(defn- write-object [m ^PrintWriter out] 
   (.print out \{)
   (loop [x m]
     (when (seq m)
       (let [[k v] (first x)]
         (when (nil? k)
           (throw (Exception. "JSON object keys cannot be nil/null")))
-	(write-json-string (as-str k) out)
+	(write-string (as-str k) out)
         (.print out \:)
         (-write-json v out))
       (let [nxt (next x)]

          (recur nxt)))))
  (.print out \}))

(defn- write-json-array [s ^PrintWriter out]
  (.print out \[)
  (loop [x s]
    (when (seq x)

          (recur nxt)))))
  (.print out \]))

(defn- write-bignum [x ^PrintWriter out]
  (.print out (str x)))

(defn- write-plain [x ^PrintWriter out]
  (.print out x))

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

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

(defn- write-generic [x out]
  (if (.isArray (class x))
    (-write-json (seq x) out)
    (throw (Exception. (str "Don't know how to write JSON of " (class x))))))

(defn- write-ratio [x out]
  (-write-json (double x) out))

;; nil, true, false
(extend nil                    JSONWriter {:-write-json write-null})
(extend java.lang.Boolean      JSONWriter {:-write-json write-plain})

;; Numbers
(extend java.lang.Number       JSONWriter {:-write-json write-plain})
(extend clojure.lang.Ratio     JSONWriter {:-write-json write-ratio})
(extend clojure.lang.BigInt    JSONWriter {:-write-json write-bignum})
(extend java.math.BigInteger   JSONWriter {:-write-json write-bignum})
(extend java.math.BigDecimal   JSONWriter {:-write-json write-bignum})

;; Symbols, Keywords, and Strings
(extend clojure.lang.Named     JSONWriter {:-write-json write-named})
(extend java.lang.CharSequence JSONWriter {:-write-json write-string})

;; Collections
(extend java.util.Map          JSONWriter {:-write-json write-object})
(extend java.util.Collection   JSONWriter {:-write-json write-array})

;; Maybe a Java array, otherwise fail
(extend java.lang.Object       JSONWriter {:-write-json write-generic})

(defn write-json
  "Write JSON-formatted output to a java.io.Writer.
   Options are key-value pairs, valid options are:

    :escape-unicode boolean

       If true (default) non-ASCII characters are escaped as \\uXXXX

    :escape-slash boolean

       If true (default) the slash / is escaped as \\/"
  [x ^Writer writer & options]
  (let [{:keys [escape-unicode escape-slash]
         :or {escape-unicode true
