A pure-Python implementation of RFC 8785 (JSON Canonicalization Scheme)
Project description
rfc8785.py
A pure-Python, no-dependency implementation of RFC 8785, a.k.a. JSON Canonicalization Scheme or JCS.
This implementation should be behaviorally comparable to Andrew Rundgren's reference implementation, with the following added constraints:
- This implementation does not transparently convert non-
str
dictionary keys into strings. Users must explicitly perform this conversion. - No support for indentation, pretty-printing, etc. is provided. The output is always minimally encoded.
- All APIs produce UTF-8-encoded
bytes
objects orbytes
I/O.
Installation
python -m pip install rfc8785
Usage
See the full API documentation here.
import rfc8785
foo = {
"key": "value",
"another-key": 2,
"a-third": [1, 2, 3, [4], (5, 6, "this works too")],
"more": [None, True, False],
}
rfc8785.dumps(foo)
yields:
b'{"a-third":[1,2,3,[4],[5,6,"this works too"]],"another-key":2,"key":"value","more":[null,true,false]}'
For direct serialization to an I/O sink, use rfc8785.dump
instead:
import rfc8785
with open("/some/file", mode="wb") as io:
rfc8785.dump([1, 2, 3, 4], io)
All APIs raise rfc8785.CanonicalizationError
or a subclass on serialization failures.
Licensing
Apache License, Version 2.0.
Where noted, parts of this implementation are adapted from Andrew Rundgren's reference implementation, which is also licensed under the Apache License, Version 2.0.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rfc8785-0.1.0.tar.gz
.
File metadata
- Download URL: rfc8785-0.1.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2264ed9efd1dd9246611dff6bcf4e95ae1b640528326816e30a31026b66aeea |
|
MD5 | 868a88e77cb242a88cadf14e9632a63f |
|
BLAKE2b-256 | 9215a7c34fcb874de2495e40bac8c8c73359003f0a8338e424fceaf740e4240c |
File details
Details for the file rfc8785-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: rfc8785-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | facd92def0ef6280d65e6342e7d89a6b970a1c96fc410f4eaf11ea9c43f2ded2 |
|
MD5 | c4169c2b75ea5b302228d086c60a6a9c |
|
BLAKE2b-256 | 9c27e39a8e4802435d29420ed4f73209533e58ecd5d051abb51c26d592ee5d71 |