Skip to main content

📜 A pure Python implementation of the Jsonnet language

Project description

📜 Pysonnet

CI Python version License pypi version

A pure Python implementation of the Jsonnet language.

Features:

  • Pure Python Implementation: Fully written in Python, ensuring compatibility and ease of integration with Python projects.
  • No External Dependencies: Operates independently without the need for any external libraries, simplifying installation and use.

[!IMPORTANT] Pysonnet is in the early stages of development. While it supports all Jsonnet syntax, it lacks some standard library features, and users might encounter bugs.

Installation

pip install pysonnet

Usage

Evaluate a jsonnet file and generate a JSON string:

import pysonnet

json_string = pysonnet.evaluate_file("path/to/file.jsonnet", ext_vars={...})

Load a string and generate a Python object:

import pysonnet

output = pysonnet.loads(
    """
    local Person(name='Alice') = {
      name: name,
      welcome: 'Hello ' + name + '!',
    };
    {
      person1: Person(),
      person2: Person('Bob'),
    }
    """
)
assert output == {
    "person1": {
        "name": "Alice",
        "welcome": "Hello Alice!"
    },
    "person2": {
        "name": "Bob",
        "welcome": "Hello Bob!"
    }
}

Evaluate file from command line:

pysonnet path/to/file.jsonnet

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

pysonnet-0.0.1.tar.gz (20.2 kB view hashes)

Uploaded Source

Built Distribution

pysonnet-0.0.1-py3-none-any.whl (22.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page