{"id":13567141,"url":"https://github.com/matrix-org/python-canonicaljson","last_synced_at":"2025-05-08T21:41:47.438Z","repository":{"id":36863143,"uuid":"41170105","full_name":"matrix-org/python-canonicaljson","owner":"matrix-org","description":"Canonical JSON","archived":false,"fork":false,"pushed_at":"2023-03-16T13:08:23.000Z","size":4797,"stargazers_count":31,"open_issues_count":3,"forks_count":15,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-02-02T03:54:36.318Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matrix-org.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-21T18:04:46.000Z","updated_at":"2023-10-26T00:06:19.000Z","dependencies_parsed_at":"2024-06-18T18:33:06.303Z","dependency_job_id":"56e365b2-0e14-4599-81e5-374160a25fce","html_url":"https://github.com/matrix-org/python-canonicaljson","commit_stats":{"total_commits":97,"total_committers":16,"mean_commits":6.0625,"dds":0.731958762886598,"last_synced_commit":"f7926e82d2c65199e5c99b54544ba17507dc63b4"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fpython-canonicaljson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fpython-canonicaljson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fpython-canonicaljson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fpython-canonicaljson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matrix-org","download_url":"https://codeload.github.com/matrix-org/python-canonicaljson/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238044095,"owners_count":19407128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:02:24.641Z","updated_at":"2025-02-10T02:11:02.582Z","avatar_url":"https://github.com/matrix-org.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Canonical JSON\n==============\n\n.. image:: https://img.shields.io/pypi/v/canonicaljson.svg\n    :target: https://pypi.python.org/pypi/canonicaljson/\n    :alt: Latest Version\n\nFeatures\n--------\n\n* Encodes objects and arrays as `RFC 7159`_ JSON.\n* Sorts object keys so that you get the same result each time.\n* Has no insignificant whitespace to make the output as small as possible.\n* Escapes only the characters that must be escaped, U+0000 to U+0019 / U+0022 /\n  U+0056, to keep the output as small as possible.\n* Uses the shortest escape sequence for each escaped character.\n* Encodes the JSON as UTF-8.\n* Can be configured to encode custom types unknown to the stdlib JSON encoder.\n\nSupports Python versions 3.7 and newer.\n\n.. _`RFC 7159`: https://tools.ietf.org/html/rfc7159\n\nInstalling\n----------\n\n.. code:: bash\n\n   pip install canonicaljson\n\nUsing\n-----\n\nTo encode an object into the canonicaljson:\n\n.. code:: python\n\n    import canonicaljson\n    assert canonicaljson.encode_canonical_json({}) == b'{}'\n\nThere's also an iterator version:\n\n.. code:: python\n\n    import canonicaljson\n    assert b''.join(canonicaljson.iterencode_canonical_json({})) == b'{}'\n\nA preserialisation hook allows you to encode objects which aren't encodable by the\nstandard library ``JSONEncoder``.\n\n.. code:: python\n\n    import canonicaljson\n    from typing import Dict\n\n    class CustomType:\n        pass\n\n    def callback(c: CustomType) -\u003e Dict[str, str]:\n        return {\"Hello\": \"world!\"}\n\n    canonicaljson.register_preserialisation_callback(CustomType, callback)\n    assert canonicaljson.encode_canonical_json(CustomType()) == b'{\"Hello\":\"world!\"}'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix-org%2Fpython-canonicaljson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrix-org%2Fpython-canonicaljson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix-org%2Fpython-canonicaljson/lists"}