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.4-cp312-cp312-win_amd64.whl (172.6 kB view details)

Uploaded CPython 3.12Windows x86-64

tson_bin-0.1.4-cp312-cp312-macosx_11_0_arm64.whl (260.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

tson_bin-0.1.4-cp312-cp312-macosx_10_12_x86_64.whl (279.0 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

tson_bin-0.1.4-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.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: tson_bin-0.1.4-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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c6492b41b5efcfa74ab504064e007028b30c534902c64538840367bfae557fc2
MD5 8b3c5eb19243516d8b75ed31e26f75bf
BLAKE2b-256 efa2a27d520be73e73d282f1eb67e0c36ca1160bf41f122748e362ac83dd97db

See more details on using hashes here.

Provenance

The following attestation bundles were made for tson_bin-0.1.4-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.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tson_bin-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7360946dede653ad939f58139c29ca9f541ae1f8292797a1d43e650b8b3d784d
MD5 bff33928dae9c1fb28695f61d63bee68
BLAKE2b-256 2c8720acf2cf01504e980afac85e37f0d923caf4fa6ea63d3e3407e7436a6221

See more details on using hashes here.

Provenance

The following attestation bundles were made for tson_bin-0.1.4-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.4-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tson_bin-0.1.4-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cb3f16694357b54a2f2b2e8addd5bcc853b83414766d8a766290e77486b08cec
MD5 2438c0bb07b21ed7866190482b3ca227
BLAKE2b-256 59488c0a1482963978c475ff7d984d860cc9abb24f23448295ec529a31ae23f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tson_bin-0.1.4-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.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tson_bin-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cb1bf598c34b8f42bf76432c64af3b09397f70beaef1182f515a2825fd7a5a6d
MD5 c35d5e92ec54eb69038537dd88a6ea60
BLAKE2b-256 c39628aa47a7f96f33b0c0aec825f289266334e8b18e63e0d8a370e18beee1c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tson_bin-0.1.4-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