Nice, but what with JavaBeans which can be contained in data structures? Beside this in future I would like to call RMI between REPL and regular Java.
What about adopting code from walk.clj by Stuart Sierra? I have made something like below so far, and frankly I won't be able to finish it by myself sine don't understand that code. Any help? (import '(java.util LinkedList ArrayList HashMap HashSet TreeSet TreeMap)) (defn walk [inner outer form] (cond (vector? form) (outer (ArrayList. (map inner form))) (map? form) (outer (let [z (map inner form)] (if (sorted? form) (TreeMap. z) (reduce #(do (.put %1 (first %2) (second %2)) %1) (HashMap.) z)) )) (set? form) (outer (let [z (map inner form)] (if (sorted? form) (TreeSet. z) (HashSet. z)) )) (list? form) (outer (ArrayList. (map inner form))) (seq? form) (outer (LinkedList. (map inner form))) :else (outer form))) (defn postwalk [f form] (walk (partial postwalk f) f form)) (defn pack[m] (postwalk identity m)) (defn pack??? [m] (let [f (fn [[k v]] (if (string? k) [(keyword k) v] [k v]))] (postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m))) (defn unpack??? [m] (let [f (fn [[k v]] (if (keyword? k) [(name k) v] [k v]))] (postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m))) Example usage (pack [ 12 23 { "a" 23 "b" 34 } ]) On 7 Maj, 20:14, Matt <macourt...@gmail.com> wrote: > You could try str and read-string functions. Though I'm not sure if > that is the safest way to do that. > > (str my-structure) > > (read-string my-string) > > -Matt Courtney > > On May 7, 11:55 am, Michael Jaaka <michael.ja...@googlemail.com> > wrote: > > > > > > > Hi! > > > I was searching for function which converts to and back all clojure > > structures like maps, vectors and sequences to serializable java > > objects. > > > But couldn't find any. Is there anyone who already done this? > > Note that with maps keywords must be converted to strings (with some > > special marker character) and after serialization back to keywords. > > Also such conversion must be done with deep recursion. It would be > > nice if ordered structures like TreeMaps were respected (I know that > > it maybe is impossible due to customizable comparator). > > > I need that because I'm doing RMI conversation between multiple > > instances of REPL (other methods of protocol are not acceptable in my > > case). > > > My proposition for names of such function is pack and unpack. > > > Thanks in advance! > > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clojure@googlegroups.com > > Note that posts from new members are moderated - please be patient with > > your first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com > > For more options, visit this group > > athttp://groups.google.com/group/clojure?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en