Calling (clojure.data.json/read-str (String. (byte-array [0]))) produces a very opaque error message (No matching clause: 0). I would like to provide a more useful message in the case of bad user-supplied data.
The current next-token implementation is:
(defn- next-token [^PushbackReader stream]
(loop [c (.read stream)]
(if (< 32 c)
(int c)
(codepoint-case (int c)
:whitespace (recur (.read stream))
-1 -1))))
Changing the last line -1 -1 to (int c) results in much more helpful messages:
(clojure.data.json/read-str (String. (byte-array [0]))) -> JSON error (unexpected character): \0
(clojure.data.json/read-str (String. (byte-array [123 0]))) -> JSON error (non-string key in object), found \0, expected "