diff options
author | Stuart Sierra <mail@stuartsierra.com> | 2009-01-26 20:57:08 +0000 |
---|---|---|
committer | Stuart Sierra <mail@stuartsierra.com> | 2009-01-26 20:57:08 +0000 |
commit | 1707eaec30e0285b268a163ebc397f50a8097b32 (patch) | |
tree | 631b0cb20eadad9215a78315212d9d8f63e10cb3 /src | |
parent | 15b478f2fad1120430f3df40678ff52ecc30710a (diff) |
json/read.clj: eliminated reflection, fixed int/char typecast bug
Diffstat (limited to 'src')
-rw-r--r-- | src/clojure/contrib/json/read.clj | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/clojure/contrib/json/read.clj b/src/clojure/contrib/json/read.clj index 897351be..8b4f69c0 100644 --- a/src/clojure/contrib/json/read.clj +++ b/src/clojure/contrib/json/read.clj @@ -23,7 +23,7 @@ (declare read-json) -(defn- read-json-array [stream] +(defn- read-json-array [#^PushbackReader stream] ;; Expects to be called with the head of the stream AFTER the ;; opening bracket. (loop [i (.read stream), result []] @@ -31,13 +31,13 @@ (cond (= i -1) (throw (EOFException. "JSON error (end-of-file inside array)")) (Character/isWhitespace c) (recur (.read stream) result) - (= c \,) (recur (char (.read stream)) result) + (= c \,) (recur (.read stream) result) (= c \]) result :else (do (.unread stream (int c)) (let [element (read-json stream)] (recur (.read stream) (conj result element)))))))) -(defn- read-json-object [stream] +(defn- read-json-object [#^PushbackReader stream] ;; Expects to be called with the head of the stream AFTER the ;; opening bracket. (loop [i (.read stream), key nil, result {}] @@ -68,7 +68,7 @@ java.io.PushbackReader." ([] (read-json *in* true nil)) ([stream] (read-json stream true nil)) - ([stream eof-error? eof-value] + ([#^PushbackReader stream eof-error? eof-value] (loop [i (.read stream)] (let [c (char i)] (cond |