jsonista icon indicating copy to clipboard operation
jsonista copied to clipboard

InputStream question

Open archaic opened this issue 4 years ago • 2 comments

Hello, I am looking to migrate from clojure.data.json to jsonista, but am unsure how to process an input stream of JSON encoded maps. Note I can't preprocess the input stream to be a vector of maps either.

In clojure.data.json I do this:

(loop [data []]
    (if-let [datom 
             (try (json/read reader)
                  (catch java.io.EOFException _)
                  (catch Exception Ex
                    (log/error Ex)))]
      (recur (conj data
                   datom))
      data))

archaic avatar Oct 21 '21 05:10 archaic

@archaic InputStream should be supported out of the box by ReadValue protocol.

Try using json/read-value.

FieryCod avatar Dec 30 '21 15:12 FieryCod

Hello, after using ReadValue on either an InputStream or Reader, it works on the first value, the second value results in a StreamClosed exception. If I get time I will dig deeper, but its not a high priority as clojure.data.json is working for me.

archaic avatar Feb 28 '22 10:02 archaic