So I have some code that is acting up when using msgpack. I have made a
minimal example below, that shows the problem. The code returns -17 (long)
when using :msgpack, but decodes correctly when using :json.
My impression was that :msgpack was base64 encoded and could be represented
as a string (and logged and so on). Is that not the case, or is something
else messing me up when I slurp the ByteArrayInputStream?
Code:
(require '[cognitect.transit :as transit])
(import [java.io ByteArrayInputStream ByteArrayOutputStream])
;; Write data to a stream
(def out (ByteArrayOutputStream.))
(transit/write (transit/writer out :msgpack) {:a [1 2]})
;; Read data from a stream -> string via slurp -> back to InputStream
(def string (slurp (ByteArrayInputStream. (.toByteArray out))))
(prn "Encoded string" string)
(def in (ByteArrayInputStream.
(.getBytes string "UTF-8")))
(def reader (transit/reader in :msgpack))
(transit/read reader)
Any idea what is going on?
/Casper
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.