On Feb 6, 2:02 pm, Peter Wolf wrote:
> How does one convert a Clojure Map to the equivalent Java Map? I bet I
> could do it in one line if I knew the magic.
To convert all keys to strings, there's clojure.contrib.walk/stringify-
keys.
-Stuart Sierra
--~--~-~--~~~---
Oops, missed the String key part -- go with Christophe's answer,
perhaps coupled with the second half of mine.
-Jason
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email
hello
Peter Wolf a écrit :
> Hello, how do I do this elegantly?
>
> I have a Clojure Map = {:foo "foo" :bah 3 ... }
>
> and I need to pass it to a Java method that is expecting a
> Map = { "foo" --> "foo" , "bah" --> 3 ...}
>
> How does one convert a Clojure Map to the equivalent Java Map? I b
AFAIK no conversion may be necessary, since Clojure maps are Java
maps.
user> (instance? java.util.Map {:foo "foo" :bah 3})
true
The only exception would be if your method expects a mutable map. In
that case,
user> (HashMap. {:foo "foo" :bah 3})
#
-Jason
On Feb 6, 11:02 am, Peter Wolf wr
Hello, how do I do this elegantly?
I have a Clojure Map = {:foo "foo" :bah 3 ... }
and I need to pass it to a Java method that is expecting a
Map = { "foo" --> "foo" , "bah" --> 3 ...}
How does one convert a Clojure Map to the equivalent Java Map? I bet I
could do it in one line if I knew t