Skip to main content

rfc8785.py

CI PyPI version Packaging status

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:

  1. This implementation does not transparently convert non-str dictionary keys into strings. Users must explicitly perform this conversion.
  2. No support for indentation, pretty-printing, etc. is provided. The output is always minimally encoded.
  3. All APIs produce UTF-8-encoded bytes objects or bytes 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.

Metadata

Release files for rfc8785 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rfc8785 0.1.4
File Size Uploaded
rfc8785-0.1.4.tar.gz 14.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rfc8785 0.1.4
File Interpreter ABI Platform
rfc8785-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 23.6 kB

Release files / rfc8785-0.1.4.tar.gz

Download URL rfc8785-0.1.4.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e545841329fe0eee4f6a3b44e7034343100c12b4ec566dc06ca9735681deb4da
BLAKE2b-256 checksum
How to use checksums
ef2ffa1d2e740c490191b572d33dbca5daa180cb423c24396b856f5886371d8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / rfc8785-0.1.4-py3-none-any.whl

Download URL rfc8785-0.1.4-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
520d690b448ecf0703691c76e1a34a24ddcd4fc5bc41d589cb7c58ec651bcd48
BLAKE2b-256 checksum
How to use checksums
4d78119878110660b2ad709888c8a1614fce7e2fab39080ab960656dc8605bf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page