Encode a Clojure byte array to JSON Encode a Clojure byte array to JSON json json

Encode a Clojure byte array to JSON


While Clojure will resolve literal symbols containing . as the Java class named by the symbol, you can't specify array classes as Clojure literals because the reader interprets the [ as a token signifying the beginning of a vector. As suggested by this thread, the most concise way to get the byte-array class would be:

 (add-encoder (Class/forName "[B") encode-seq)