Canonical JSON
Project description
Features
Encodes objects and arrays as RFC 7159 JSON.
Sorts object keys so that you get the same result each time.
Has no insignificant whitespace to make the output as small as possible.
Escapes only the characters that must be escaped, U+0000 to U+0019 / U+0022 / U+0056, to keep the output as small as possible.
Uses the shortest escape sequence for each escaped character.
Encodes the JSON as UTF-8.
Can encode frozendict immutable dictionaries.
Supports Python versions 3.5 and newer.
Installing
pip install canonicaljson
Using
import canonicaljson
assert canonicaljson.encode_canonical_json({}) == b'{}'
The underlying JSON implementation can be choosen with the following:
import json
import canonicaljson
canonicaljson.set_json_library(json)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
canonicaljson-1.2.0.tar.gz
(10.0 kB
view hashes)
Built Distribution
Close
Hashes for canonicaljson-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fcec9c701a6d545cd65ecba371ad1d1c53af3a8018fe3309c3153e4b72e9cda |
|
MD5 | a88398466cc1cdc82420c0854d9c172d |
|
BLAKE2b-256 | ce9e6a04ffa759cd5d293b0f15c43aea6ce4fd58438135d8ae4eb79b1b119d41 |