RFC 8785 JSON Canonicalization Scheme (JCS) extension for metosin/jsonista.
dev.dotfox/jsonista.jcs {:mvn/version "1.0.9"}
or as a git dependency
io.github.DotFox/jsonista.jcs {:git/tag "v1.0.9" :git/sha "2ed4c9d"}
and prep java sources
clj -X:deps prep
[dev.dotfox/jsonista.jcs "1.0.9"]
(require '[jsonista.core :as json] '[jsonista.jcs :as jcs])
;; jcs/object-mapper expects the same arguments as json/object-mapper
(def jcs-object-mapper (jcs/object-mapper))
;; with custom object-mapper the result will be brought in line with the RFC 8785
(json/write-value-as-string obj jcs-object-mapper)
- The numbers are serialised according to Section 7.1.12.1 of ECMA-262
- Object keys are sorted recursively using serialized form. Custom
:encode-key-fn
will be used if provided. - Unicode code points in strings serialized to lowercase.