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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

tson_bin-0.1.3-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.3-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.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: tson_bin-0.1.3-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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8740915d37de8a9cfc3fa9639ecd7c50681f872292034f5854b42615ece5ba15
MD5 ca78848358038dec2b4c9cbe8bbaa4ce
BLAKE2b-256 43004ef4b219d7978f4e3eaf39dfc82d91f23782a2c7695626b4a677cce32ded

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tson_bin-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f7b6452d7231bec3b8d136dfd4891a37fc6b226c144db91dfa8cb12a8addc0f0
MD5 a899db584230133e6c15d69c4ea9d428
BLAKE2b-256 a2c6846a1579a781b3c33bb958f83e81496ce86e2ec9ff7f8e6f7aab7b0f94b9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tson_bin-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9e9b215cc3967d75141a70ac1fe7e2aaf0f1b2ea6ea3ada8073aa826505ad133
MD5 809f2e42e692d923732f884d7381337c
BLAKE2b-256 9b4804a905f5d5cb127d2584a3ae7fb07619a71534f7f19e564a06ddedba5488

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tson_bin-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b82e5ee97804e52a900fdffba3368d18e7646617fb05cd8ff3f90bf82468bb5a
MD5 e434e3b48aca25c8d22e4c23e124c5c4
BLAKE2b-256 9d7ab7702e46a14a96202418bc2375947e799020167d095d0b2b19357f281dcb

See more details on using hashes here.

Provenance

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