Skip to main content

Terse JSON — compact binary JSON for microcontrollers

Project description

tson-bin — Terse JSON binary format for Python

PyPI License: MIT

TSON is a compact, schema-deduplicated binary format for JSON — field names are stored once, repeated strings are interned, giving 60–70% size reduction on repetitive data (API payloads, telemetry, config). These are the Python bindings (a native extension built in Rust via PyO3).

The PyPI distribution is tson-bin but it imports as tson.

Install

pip install tson-bin
import tson

Usage

import tson

# Compile a JSON string to TSON binary, and back
blob = tson.dumps('{"name": "Alice", "age": 30}')   # -> bytes
obj  = tson.loads(blob)                               # -> {"name": "Alice", "age": 30}

# Encode a Python object directly (no JSON string in between)
blob = tson.emit({"temp": 22.5, "status": "nominal"})

# File I/O
tson.dump('{"msg": "hello"}', "message.tson")
obj = tson.load("message.tson")

API

Function Signature Description
dumps(json_text) str -> bytes Compile a JSON string to TSON binary
loads(blob) bytes -> object Decode TSON binary to a Python object
dump(json_text, path) (str, str) -> None Compile a JSON string to a .tson file
load(path) str -> object Read and decode a .tson file
emit(obj) object -> bytes Encode a Python object directly to TSON

Invalid input raises ValueError.

Documentation

License

MIT © SIKTEC Lab

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tson_bin-0.1.2-cp312-cp312-win_amd64.whl (172.6 kB view details)

Uploaded CPython 3.12Windows x86-64

tson_bin-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (260.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

tson_bin-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl (279.1 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

tson_bin-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (293.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file tson_bin-0.1.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: tson_bin-0.1.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 172.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tson_bin-0.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 636b7a8e972d88a26404607fac9aa889f46a5f5a30dd1e92847194413334a041
MD5 b270604557eb6b9c47965f5fe1193d61
BLAKE2b-256 a6f609e33d85518289dc3753d1d184a8d521ea9f145e77ca27901a98e8b4a3be

See more details on using hashes here.

Provenance

The following attestation bundles were made for tson_bin-0.1.2-cp312-cp312-win_amd64.whl:

Publisher: release.yml on siktec-lab/tson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tson_bin-0.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tson_bin-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e953a387d27b2b9bd177a2d3ece4a2d67bbd0123752f4ad665f78bb9beb2d569
MD5 17722a95c22a522fd6edc96cf20a9fe6
BLAKE2b-256 a01d6c391b44246126560b1ce830c44753fc7a00ebbc69bc733d70c24b34e43f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tson_bin-0.1.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on siktec-lab/tson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tson_bin-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tson_bin-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2b6f0fd66f4dc633a8fc7a076a68cf7ec2bdb35e3176e01e2f00de089fbcd462
MD5 0e0a8d7a298068da7c9aaa634bd0a336
BLAKE2b-256 098c91965c9013eea397b071fca36e38f122815e635d023eb13b5a5ccdbf99a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tson_bin-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: release.yml on siktec-lab/tson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tson_bin-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tson_bin-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e6eadade43f079fac0c2089878317bc1d011fdf4c54b436ed48c570f501e1f5
MD5 957399a70e16481f598082288aa8db4f
BLAKE2b-256 0bc3c210826f97dbe7692c8799ed079efc24d86d1075893f1c0d047556703603

See more details on using hashes here.

Provenance

The following attestation bundles were made for tson_bin-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on siktec-lab/tson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page