Closed jerger closed 4 years ago
It is possible to write such a map as
#:dda.provision{:provisioner :dda.provision.dry-run/dry-run
:user "user"
:module "dda-provision"
:sub-module "should-execute"
:filename "aFile"}
These namespaced maps where introduced in Clojure 1.9 (https://clojure.org/reference/reader#_maps). They are not mentioned in EDN format specification (awaiting BNF). Namespaced maps works when reading EDN with clojure.edn
in versions >= 1.9:
(clojure.edn/read-string "#:a{:b 1 :c 1}")
#:a{:b 1, :c 1}
If you specify other qualified keys inside the map the namespace in front of the map vanishes:
(clojure.edn/read-string "#:a{:b 1 :c 1 :other/test 2}")
{:a/b 1, :a/c 1, :other/test 2}
As you can see above the default namespace a
is overridden by giving a qualified keyword inside the map (like :other/test
).
I do not know if this functionality is supported in other EDN-readers.
also see #78
Hi, as we're using spec with namespaced keywords, our edn's get bloated with the namespace part like:
namespace alias would be great in order to raise the semantic per boilerplate ratio. Comparable problem is solved e.g. in RDF (full example at https://www.w3schools.com/XML/xml_rdf.asp):
Is there a comparable solution in edn ?