0
有没有办法指示clojure.core.edn/read
如何解析自动命名空间关键字?Clojure edn读取自动命名空间关键字
(edn/read-string "{:not-namespaced \"ko\" }") ;;=> {:not-namespaced "ko"}
(edn/read-string "{:namespaced/ok \"ko\" }") ;;=> #:namespaced{:ok "ko"}
(edn/read-string "{::namespaced \"ko\" }") ;;=> Unhandled java.lang.RuntimeException Invalid token: ::namespaced autonamespaced does not work
最后一个例外是有道理的,因为"A keyword cannot begin with ::"。
我可以使用load-file
这个简单的例子,但是我也需要edn
(读取自定义标签)的可扩展性。
有一个参数指示如何解析命名空间将使我的配置文件(强制使用clojure.spec
)更具可读性。
你尝试过使用'clojure.core/read-string'吗? – OlegTheCat
@OlegTheCat有趣,我没有!尽管如此,我不得不去挖掘它的选项图。 – nha
@OlegTheCat据我所知,clojure.core/read-string将不会让我有像edn这样的读者。这将阻止我在https://github.com/juxt/aero中定义的配置(否则可能有效)。 – nha