Skip to main content

JSON renderer for t-string structured data templates

Project description

json-tstring

JSON rendering for PEP 750 t-strings. Parsing and rendering happen in Rust; this package is the Python wrapper.

Requires Python 3.14+.

This package depends on tstring-bindings, a native PyO3 extension. On supported platforms, install from prebuilt wheels. Other environments require a local Rust 1.94.0 toolchain build.

API

render_data(template, profile="rfc8259")  # -> Python data
render_text(template, profile="rfc8259")  # -> JSON text
render_result(template, profile="rfc8259")  # -> RenderResult (.text + .data)

Type alias: JsonProfile = Literal["rfc8259"]

Parsed template structure is cached per process using template.strings + profile as the key.

How it works

The Python Template is converted to a Rust token stream, parsed into JSON nodes (keeping interpolation visible in values, keys, and string fragments), and rendered back to text or Python data. serde_json handles normalization.

Supported positions

  • whole-value, object-key, quoted-key-fragment, and string-fragment interpolation
  • bare fragments promoted to JSON strings
  • nested arrays and objects, top-level values

Limits

  • object keys must be str
  • non-finite floats rejected
  • values must be JSON-representable
  • integers keep exact Python text (no silent float coercion)

Verify

uv sync --group dev
uv run --group dev pytest

See also

Project details


Download files

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

Source Distribution

json_tstring-0.2.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

json_tstring-0.2.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file json_tstring-0.2.2.tar.gz.

File metadata

  • Download URL: json_tstring-0.2.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for json_tstring-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ca47c301a0ab23e8b6e68789399742f2338ac0a0c73afbd2322a2cbf5f617cd3
MD5 9ffb234ad46eb3fe5c1e299efdb4eaaa
BLAKE2b-256 5d70c7e9c2ccfebc739fd0d854faa9a5818e8f405282d53acb6c616a88cd653c

See more details on using hashes here.

Provenance

The following attestation bundles were made for json_tstring-0.2.2.tar.gz:

Publisher: publish-python.yml on koxudaxi/tstring-structured-data

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

File details

Details for the file json_tstring-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: json_tstring-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for json_tstring-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d30357975ecc082d81ade30972972c3f5ecc8d2ee07c39d76a97d6ff205f1bec
MD5 11a0ae89840bd2896ad481d8ffb19314
BLAKE2b-256 76e061365cafad6c07fbc6d62c3d1315adb849a01c1e6979d61a1791a60a0a81

See more details on using hashes here.

Provenance

The following attestation bundles were made for json_tstring-0.2.2-py3-none-any.whl:

Publisher: publish-python.yml on koxudaxi/tstring-structured-data

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