 (defmethod encode :clojure [session message options]
   "Stringify a clojure data structure"
   (set-encoding
-   (.createTextMessage session (with-out-str
-                                 (binding [*print-dup* true]
-                                   (pr message))))
+   (.createTextMessage session (core/encode message))
    :clojure))
 
 (defmethod encode :json [session message options]
   "Stringify a json data structure"
   (set-encoding
-   (.createTextMessage session (json/json-str message))
+   (.createTextMessage session (core/encode message :json))
    :json))
 
 (defmethod encode :text [session message options]


(defmethod decode :clojure [message]
  "Turn a string into a clojure data structure"
  (load-string (.getText message)))

(defmethod decode :json [message]
  "Turn a string into a json data structure"
  (json/read-json (.getText message)))

(defmethod decode :text [message]
  "Treats the message payload as a raw string. No decoding is done."

;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.

(ns immutant.messaging.codecs
  (:require [immutant.codecs :as core]))

(def encoding-header-name "__ContentEncoding__")

