我怎样才能将字符串解析为打嗝?

Hen*_*Zhu 5 clojure hiccup clojurescript om reagent

如何将一串Hiccup解析为打嗝节点?

例如, "[:b 'hello world']"进入[:b "hello world"]

edb*_*ond 3

使用 reader 将字符串转换为数据结构:

user=> (clojure.edn/read-string "[:b 'hello world']")
[:b 'hello world']
Run Code Online (Sandbox Code Playgroud)

您应该使用"来表示字符串:

user=> (clojure.edn/read-string "[:b \"hello world\"]")
[:b "hello world"]
Run Code Online (Sandbox Code Playgroud)

  • 谢谢!对于那些使用 Clojurescript 的人,您需要 `[cljs.reader]` (2认同)