Skip to main content

Homogenous JSON template engine

Project description

transon

PyPI PyPI - Python Version Codecov PyPI - Downloads

Homogenous JSON template engine. transon creates JSON out of template and JSON input.

                    ┌─────────────────┐
                    │  JSON Template  │
                    └────────┬────────┘
                             │
┌──────────────┐    ┌────────▼────────┐    ┌───────────────┐
│  JSON Input  ├────►     transon     ├────►  JSON Output  │
└──────────────┘    └─────────────────┘    └───────────────┘

Documentation and playground: https://transon-org.github.io/

transon is a powerful and flexible JSON template engine that enables developers to transform JSON data using a customizable set of rules. With transon, you can generate dynamic templates, manipulate JSON data, and produce new JSON structures that meet your specific requirements.

Development Principles

transon was built with a set of key development principles in mind, including:

  • Flexibility and Extensibility: transon is designed to be highly flexible and extensible, allowing you to add new rules and types of placeholders to suit your unique needs.
  • Valid JSON Structure: transon templates are defined as valid JSON structures, making them easy to work with and compatible with a wide range of tools and applications.
  • Composable Rules: transon rules are highly composable, allowing you to define complex behavior patterns using a combination of nested rules. For example, arithmetic expressions can be defined with nested rules, where each rule represents a specific operation. This approach eliminates the need for a domain-specific language (DSL) for arithmetic expressions.
  • Marker-Based Templates: The most important aspect of a transon template is the use of the $ marker. This marker is a special key within the JSON structure that distinguishes it from other types of JSON data. By default, the $ key is used as the marker, but you can change it to any other value you prefer.

By using a marker-based approach, transon ensures that templates are easy to work with and can be easily distinguished from other types of JSON data. This makes it simple to generate dynamic templates, manipulate JSON data, and produce new JSON structures that meet your specific requirements. Additionally, the composable rules approach allows for advanced behavior patterns that can be defined using a combination of nested rules, making transon highly flexible and extensible.

Installation

transon can be installed using pip, the Python package manager. Simply run the following command:

pip install transon

Development

Requires Python 3.9+ and uv.

uv sync --dev
uv run pytest .

Inspired by

Analogues

json-template - a lightweight JSON template engine for JavaScript that provides a simple way to generate JSON data from templates. It supports placeholders for data values, expressions, and conditions, and can be used to generate complex JSON data structures.

jsonnet - a flexible templating language for generating JSON data that is used by companies like Google, Uber, and Red Hat. It allows developers to define templates using a domain-specific language that supports expressions, conditions, and functions.

jolt - a JSON-to-JSON transformation library that allows developers to define transformation specifications using a simple and intuitive syntax. It supports a wide range of transformation operations, including mapping, filtering, sorting, and grouping.

jsonata - a powerful data transformation language for JSON data that supports complex queries, transformations, and aggregations. It can be used to generate JSON output from input data or transform JSON data into other formats.

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

transon-0.0.10.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

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

transon-0.0.10-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file transon-0.0.10.tar.gz.

File metadata

  • Download URL: transon-0.0.10.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for transon-0.0.10.tar.gz
Algorithm Hash digest
SHA256 7738b9f83b370db9d04bf2657e9985cc8a1ae2f70274518b493b5111452c3cd6
MD5 43f61eb6a5c1236010df9db2f490d016
BLAKE2b-256 1a3012ea181965c59f6140e4e93a32015f1756af4e06dc052d538f3a3dfb11cd

See more details on using hashes here.

File details

Details for the file transon-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: transon-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for transon-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 e3ad9d4499bafb5cbb91da7a1cd6c0580adf02a85f47b131b6ff5738e7456aa6
MD5 0c2bb3bff9dd26addd8e363429391542
BLAKE2b-256 618e5e4322bb590dc42b4cc8d7245873f9421cb7e811bcec280b200fcb48273f

See more details on using hashes here.

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