如何转换地图到URL查询字符串在Clojure / Compojure / Ring? [英] How to convert map to URL query string in Clojure/Compojure/Ring?
本文介绍了如何转换地图到URL查询字符串在Clojure / Compojure / Ring?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Clojure / Compojure中,如何将地图转换为网址查询字符串?
{:foo 1:bar 2:baz 3}
到
foo = 1& bar = 2& baz = 3
$ p $
解决方案是否有任何实用方法可以在compojure中执行? ,有一个实用程序已经不涉及Hiccup或滚动自己的字符串/ join / URLEncoder函数:
用户=> (ring.util.codec / form-encode {:foo 1:bar 2:baz 3})
foo = 1& bar = 2& baz = 3
user =>
Compojure取决于ring / ring-core,其中包括ring.util.codec,
In Clojure / Compojure, how do I convert a map to a URL query string?
{:foo 1 :bar 2 :baz 3}
to
foo=1&bar=2&baz=3
Is there any utility method to do this in compojure?
解决方案Yes, there is a utility for this already that doesn't involve Hiccup or rolling your own string/join/URLEncoder function:
user=> (ring.util.codec/form-encode {:foo 1 :bar 2 :baz 3}) "foo=1&bar=2&baz=3" user=>
Compojure depends on ring/ring-core, which includes ring.util.codec, so you already have it.
这篇关于如何转换地图到URL查询字符串在Clojure / Compojure / Ring?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文