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.11.tar.gz (25.2 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.11-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: transon-0.0.11.tar.gz
  • Upload date:
  • Size: 25.2 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.11.tar.gz
Algorithm Hash digest
SHA256 070aaf016db70e9d4b2597cb3b96f0ff5d27d532a474617d5d6a65df5680e46f
MD5 8934f9fcc2e709886101bd98cdc42216
BLAKE2b-256 ba9f952119c7451a45e97aff55e24cba27139d471c14f69d2780cd331b7cf647

See more details on using hashes here.

File details

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

File metadata

  • Download URL: transon-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 30.3 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.11-py3-none-any.whl
Algorithm Hash digest
SHA256 1d3cada6517a1ed96fa4871c2a0b5ed1a446d59bd16f5d471d6bdbb2ee929325
MD5 1ffe8d9b0b1daf7f652a8a3cb33cff06
BLAKE2b-256 5649bf490399aa1e30ad5d1b9d6f2a9030fdeed48e2ced2f7d0737d6b8d27548

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