Actually, I shouldn't have worded this as a json issue. It's really a
core problem that keywords with spaces can't be serialized/
deserialized.
A keyword is basically a String, and the language definition does not
preclude keywords from having spaces.
(keyword "a b c") works, and so does (get m (keyword "a b c")) - on an
appropriately created map

Cheers.


On Feb 27, 3:55 pm, MarkSwanson <mark.swanson...@gmail.com> wrote:
> Hello,
>
> Consider the following valid JSON:
>
> Clojure=> (def mq "{\"Question one\":\"test\"}")
> #'user/mq
> Clojure=> (read-json mq)
> {:Question one "test"}
>
> So the default behaviour fails to work correctly for a common case.
>
> The Clojure failure is not exactly obvious either:
>
>  (read-string (str mq))
>
> request failed java.lang.RuntimeException:
> java.lang.ArrayIndexOutOfBoundsException: 19
>     at clojure.lang.RT.readString(RT.java:1220)
>     at clojure.core$read_string__4163.invoke(core.clj:2517)
>
> I also tried with print-dup and it fails the same way:
> =>(def ms (new StringWriter))
> =>(print-dup mq ms)
> =>(. ms toString)
> "#=(clojure.lang.PersistentArrayMap/create {:Question one \"test\"})"
> =>(read-string (. ms toString))
> #<CompilerException java.lang.RuntimeException:
> java.lang.ArrayIndexOutOfBoundsException: 3 (REPL:65)>

-- 
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

Reply via email to