Skip to main content

Homogeneous JSON template engine

Project description

transon

PyPI PyPI - Python Version Codecov PyPI - Downloads

Homogeneous 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.12.tar.gz (30.5 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.12-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: transon-0.0.12.tar.gz
  • Upload date:
  • Size: 30.5 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.12.tar.gz
Algorithm Hash digest
SHA256 1f60304285010ad7fe4de5fe574d3ce2eab16d164778ffaa0ca2731da4c1770a
MD5 74292c573f43c77263a12663ea28ec5d
BLAKE2b-256 ae7ac3405344763573336a573bf1b2c87a19011f326906e133df4bd82c41656c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: transon-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 36.2 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.12-py3-none-any.whl
Algorithm Hash digest
SHA256 74df472da9c2e279e1178165f8577be31c9920957ff336b6d2f420f713d20cf7
MD5 2d0294a43051fb996bafda447584b9d5
BLAKE2b-256 f2c4072beaaa287ea91db1d70abb89fd587bfcf401681d376bd2ae58f8af6940

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