https://github.com/dotfox/jsonista.jcs
RFC 8785 JSON Canonicalization Scheme (JCS) for metosin/jsonista
https://github.com/dotfox/jsonista.jcs
canonicalization clojure json jsonista rfc-8785
Last synced: 2 months ago
JSON representation
RFC 8785 JSON Canonicalization Scheme (JCS) for metosin/jsonista
- Host: GitHub
- URL: https://github.com/dotfox/jsonista.jcs
- Owner: DotFox
- License: mit
- Created: 2023-01-23T13:02:43.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-26T11:51:08.000Z (almost 3 years ago)
- Last Synced: 2025-09-21T21:41:04.650Z (3 months ago)
- Topics: canonicalization, clojure, json, jsonista, rfc-8785
- Language: Java
- Homepage:
- Size: 23.4 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsonista.jcs
[RFC 8785 JSON Canonicalization Scheme (JCS)](https://www.rfc-editor.org/rfc/rfc8785) extension for [metosin/jsonista](https://github.com/metosin/jsonista).
## deps.edn
```clojure
dev.dotfox/jsonista.jcs {:mvn/version "1.0.9"}
```
or as a git dependency
```clojure
io.github.DotFox/jsonista.jcs {:git/tag "v1.0.9" :git/sha "2ed4c9d"}
```
and prep java sources
```shell
clj -X:deps prep
```
## project.clj
```clojure
[dev.dotfox/jsonista.jcs "1.0.9"]
```
# TLDR;
## Create custom `object-mapper`
```clojure
(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)
```
# Differences in compare with default `jsonista.core/object-mapper`
1. The numbers are serialised according to Section 7.1.12.1 of [ECMA-262](https://www.rfc-editor.org/rfc/rfc8785#ECMA-262)
2. Object keys are sorted recursively using serialized form. Custom `:encode-key-fn` will be used if provided.
3. Unicode code points in strings serialized to lowercase.