transit metadata keys

We were surprised to learn today that transit-clj cannot encode metadata on keys.

Given the following deps.edn

{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
				com.cognitect/transit-clj {:mvn/version "1.0.324"}}}
deps.edn

We start with some setup taken from transit.clj#L389-L407:

(require 'cognitect.transit)
(in-ns 'cognitect.transit)
(import [java.io File ByteArrayInputStream ByteArrayOutputStream OutputStreamWriter])
(def out (ByteArrayOutputStream. 2000))
(def w (writer out :json {:transform write-meta}))
0.1s
Clojure
'cognitect.transit/w

Trying to write a map {'key 'val} with metadata on the value works:

(write w {'key (with-meta 'val {:foo 'bar})})
0.0s
Clojure

But trying to write a map {'key 'val} with metadata on the key errors:

(write w {(with-meta 'key {:foo 'bar}) 'val})
0.0s
Clojure
Runtimes (1)