5

How can I parse a string of Hiccup into a Hiccup node?

For example, "[:b 'hello world']" into [:b "hello world"]

Alex Miller
  • 69,183
  • 25
  • 122
  • 167
hzhu
  • 3,759
  • 5
  • 29
  • 39

1 Answers1

3

Use reader to convert string to data structures:

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

You should use " to denote string:

user=> (clojure.edn/read-string "[:b \"hello world\"]")
[:b "hello world"]
edbond
  • 3,921
  • 19
  • 26