有没有在Clojure中解析Clojure数据结构的读取函数?我的使用情况是读取配置属性文件,其中一个属性的值应该是一个列表。我希望能够这样写:
file.properties:
file.properties:
property1 = ["value1" "value2"]
在Clojure中:
(load-props "file.properties")
并获得一个值为{property1,["value1" "value2"]}的映射
目前我正在执行以下操作,使用相同的输入文件"file.properties":
(defn load-props [filename]
(let [io (java.io.FileInputStream. filename)
prop (java.util.Properties.)]
(.load prop io)
(into {} prop)))
;; returns:
;; {"property1" "[\"valu1\", \"valu2\"]"}
(load-props "file.properties")
但是我无法找到一种将结果解析为Clojure向量的方法。我基本上正在寻找类似于Erlang的file:consult/1函数的东西。有什么想法吗?