Continuing the discussion from Slack: Jsonista 0.3.0 ships with support for tagged json, which allows one to write lossless encoding data using tagged values, like Transit, but with much better performance.
It looks like this:
(require '[jsonista.core :as j])
(require '[jsonista.tagged :as jt])
(def mapper
(j/object-mapper
{:encode-key-fn true
:decode-key-fn true
:modules [(jt/module
{:handlers
{Keyword {:tag "!kw"
:encode jt/encode-keyword
:decode keyword}
PersistentHashSet {:tag "!set"
:encode jt/encode-collection
:decode set}}})]}))
(-> {:system/status #{:status/good}}
(j/write-value-as-string mapper)
(doto prn)
(j/read-value mapper))
; prints "{\"system/status\":[\"!set\",[[\"!kw\",\"status/good\"]]]}"
; => {:system/status #{:status/good}}
The question is: what should happen next? Many people seem to want “a faster transit” built on top of Jsonista, which would require:
- adding support for ClojureScript
- implementng tag-handlers for all basic Clojure/Java types
- adding support for tagged keys (now: just values)
Would be tempting just to do those, but
- would it be better to contribute perf improvements to current Transit? Transit2?
- Are there any non-clojure JSON tagging systems out there, which we could implement here and be more compatible with the rest of the world?
PS. @borkdude pointed out that JSON Schema draft 7 has support for non-json-data.