           ;; Read JSON arrays
           \[ (parse-array stream)
 
-          (throw (Exception. (str "JSON error (unexpected character): " (char c)))))))))
+          (throw (Exception.
+                  (str "JSON error (unexpected character): " (char c)))))))))
 
 (defn parse [rdr & options]
   (let [{:keys [keywordize eof-error? eof-value]

  ([string & options]
     (apply parse (PushbackReader. (StringReader. string)) options)))

;;; JSON PRINTER

(defprotocol Write-JSON
  (write-json [object out escape-unicode?]
    "Print object to PrintWriter out as JSON"))

(defn- write-json-string [^CharSequence s ^PrintWriter out escape-unicode?]
  (let [sb (StringBuilder. ^Integer (count s))]
    (.append sb \")
    (dotimes [i (count s)]
      (let [cp (int (.charAt s i))]
        (codepoint-case cp
          ;; Handle printable JSON escapes before ASCII
          \" (.append sb "\\\"")
          \\ (.append sb "\\\\")
          \/ (.append sb "\\/")
          ;; Print simple ASCII characters
          :simple-ascii (.append sb (.charAt s i))
          ;; Handle JSON escapes
          \backspace (.append sb "\\b")
          \formfeed  (.append sb "\\f")
          \newline   (.append sb "\\n")
          \return    (.append sb "\\r")
          \tab       (.append sb "\\t")
          ;; Any other character is Unicode
          (if escape-unicode?
            ;; Hexadecimal-escaped
            (.append sb (format "\\u%04x" cp))
            (.appendCodePoint sb cp)))))
    (.append sb \")
    (.print out (str sb))))

        to turn off \\uXXXX escapes of Unicode characters."
  [x & options]
  (let [{:keys [escape-unicode] :or {escape-unicode true}} options]
    (pprint/write x :dispatch #(pprint-json-dispatch % escape-unicode))))

;; Local Variables:
;; mode: clojure
