vert-x / mod-lang-clojure

Vert.x 2.x is deprecated - use instead
http://vertx.io
Other
74 stars 15 forks source link

http/end with map? #121

Closed zhaopuming closed 10 years ago

zhaopuming commented 10 years ago

I want to response with a JSON format data, like:

{"3":4,"2":1,"1":5}

but when I do this:

(http/end (str result))

I got this:

{:3 4, :2 1, :1 5}

Now I have to do a trick to force encod in JSON:

; in (ns) block
(:require [vertx.utils :refer :all])

(http/end (str (encode result)))

Is this the prefered approach? Or is there an convenient method like (json result)?

tobias commented 10 years ago

If you need your data encoded in a specific format, you're responsible for doing that encoding. There currently isn't any util methods that give you back a json string, You can easily define your own method as (def json (comp str vertx.utils/encode)).

zhaopuming commented 10 years ago

Thanks for the clarification, I'll define my own function :-)