Cbor-J
Lightweight pure-Python library to encode/decode JSON strings to/from CBOR — with optional zlib compression.
Perfect for reducing storage size of large JSON files.
Features
- Pure Python, no dependencies
- Simple API:
encode(json_str, compress=False) → bytes,decode(bytes, compress=False) → str - Optional zlib compression (like EU Digital COVID Certificate format, without signing/Base45)
- Includes CLI tool
Installation
pip install cborJ
Usage
import json
from cborJ import decode, encode
json_data = {
"name": "Alice",
"age": 30,
"email": "alice@example.com",
"isMember": True,
"favorites": {
"color": "blue",
"food": "pizza"
},
"shoppingList": ["eggs", "milk", "bread"]
}
json_str = json.dumps(json_data)
print("--------------Encoding--------------")
# Encode → (no compression)
encoded = encode(json_str, compress=False)
print(f"Original: {json_str.encode()}\n")
print(f"CBOR: {encoded}\n")
# Encode → (with compression)
encoded_zip = encode(json_str, compress=True)
print(f"Original: {json_str.encode()}\n")
print(f"CBOR: {encoded_zip}\n")
print("--------------Decoding--------------")
# Decode → (with compression)
decoded_zip = decode(encoded_zip, compress=True)
print(f"CBOR: {encoded_zip}\n")
print(f"Original: {decoded_zip.encode()}\n")
CLI Tool
Encode JSON file to CBOR (stdout)
cborJ encode data.json > data.cbor
Decode back
cborJ decode data.cbor > data.json
With compression
cborJ encode --compress big.json > big.cbor
Metadata
Release files for cborJ 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cborj-0.1.1.tar.gz | 6.6 kB | Without provenance | Details for cborj-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cborj-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for cborj-0.1.1-py3-none-any.whl |
Total release size: 12.8 kB
Release files / cborj-0.1.1.tar.gz
| Download URL | cborj-0.1.1.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9714bc70c8845d341bac789790329c611cc81932e2a584c748b627172812f4fb
|
|
BLAKE2b-256 checksum How to use checksums |
7e52e54c9a820a0a1568a604d97a7be2ec398e15344ff0ef6be8e9794d75fa39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Release files / cborj-0.1.1-py3-none-any.whl
| Download URL | cborj-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5bfbedf33c1ceb37539469d4d38abea30d786a77061232f77887cf371514ad37
|
|
BLAKE2b-256 checksum How to use checksums |
976a5f9440fd4f91bfcb1cb27d8014049a8bfc090a02e3006b13807ae814b580
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Security for cborJ 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.