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

Uploaded CPython 3.12Windows x86-64

tson_bin-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (260.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

tson_bin-0.1.1-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.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (293.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: tson_bin-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 172.5 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 81972087547c14581bf755c94412ee296e2140e9f41e9d4cf4b1aacfaecc21b7
MD5 1b57a096bb14d6b8f70b591121358506
BLAKE2b-256 ce6ca228931bc513ac21f3811c822d6abb1ee6686211a5dc5a693ca96a0a7217

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tson_bin-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d06326d9c23919ba7f35e73daeeba209e76c838ad2533627e53ecdfae0eeb9cf
MD5 e1a62ae994559979686c8369c1b21282
BLAKE2b-256 ae07db45c5fb972536736ace829b8d28a49bea4767e4cd483d7c91b296f66808

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tson_bin-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2fa399ec2160b24efe5366d40e7f2a747902904836563f2621ea383bc16069cd
MD5 1f6b1ab9c1270c4a1ee1bc2bb7a8d329
BLAKE2b-256 0679245ce7c31f525718a7198bef060cd42bde16d8d9c8ba8fb27bbc43373e66

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tson_bin-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d72bff038d1f566c83d1c079a4fc885ab24b55aa3ee7d106c8783436bfe1489
MD5 88fd9d85a7aa26bfe225076455d37bf9
BLAKE2b-256 972629f97af3e3c3f3db693eefb809f5acb5797c8c2776f3544a95252d630d71

See more details on using hashes here.

Provenance

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