Python bindings for Jsonnet - The data templating language
Project description
Jsonnet - The data templating language
For an introduction to Jsonnet and documentation, visit our website.
This is the Python module for the original C++ implementation of Jsonnet.
Security notes: The C++ implementation is not suitable for processing untrusted inputs without significant external effort to sandbox it. It is not hardened and may have unknown exploitable bugs. It is intended for use to evaluate Jsonnet code that you trust not to be malicious (e.g., code written by you/your organisation). Even ignoring the risk of exploitable bugs in the implementation, the import, importstr, and importbin language constructs can potentially be used to exfiltrate sensitive data unless you take extra steps to restrict these or sandbox the jsonnet interpreter. By default, these constructs can import from any path accessible to the interpreter process.
Using the Jsonnet Python module
You can install from PyPI with uv add jsonnet or with your preferred Python package management tool.
The two main functions in the _jsonnet package are evaluate_file and evaluate_snippet:
evaluate_file(filename, ...)reads and evalutes the file at the given path, returning an output as a JSON string.evaluate_snippet(filename, src, ...)evaluates the given source code (src), returning an output as a JSON string. The provided filename is used in error messages.
The functions support keyword arguments:
jpathdir: A string (path to a directory) or list of strings (list of directories) to be added to the import search path.ext_vars,ext_codes: Dictionaries of variables to set; these can be used from within the evaluated code through thestd.extVarJsonnet function.ext_codesvalues are Jsonnet expressions,ext_varsvalues are provided to Jsonnet as plain strings.tla_vars,tla_codes: Dictionaries of Top-Level arguments. If the provided Jsonnet code to evaluate represents a function, that function is called with these values as (named) arguments.import_callback: A function which will be called whenimport(orimportstr,importbin) expressions are evaluated. See below.native_callbacks: A dictionary of functions which can be called from Jsonnet using the Jsonnetstd.nativefunction. See below.
And some configuration for internal implementation details:
max_stackmax_tracegc_min_objectsgc_growth_trigger
import_callback
Usage example:
import _jsonnet
FILES = {
"the_message.txt": b"hello, world",
}
def import_callback_memfile(dir, rel):
"""Custom import function which only returns files from some in-memory storage.
Args:
dir: The directory part of the file in which the `import` occurred.
rel: The path string passed to the `import` expression.
"""
if rel in FILES:
# Note that the returned file _content_ should be a bytes value, not a string.
return rel, FILES[rel]
raise RuntimeError('File not found')
result = _jsonnet.evaluate_snippet(
'example',
'local the_message = importstr "the_message.txt"; ' +
'{ msg: the_message }',
import_callback=import_callback_memfile)
assert result == '{\n "msg": "hello, world"\n}\n';
native_callbacks
Usage example:
import _jsonnet
def concat(a, b):
return a + b
native_callbacks = {
'concat': (('a', 'b'), concat),
}
result = _jsonnet.evaluate_snippet(
'example',
'local concat = std.native("concat"); ' +
'concat("hello, ", "world")',
native_callbacks=native_callbacks)
assert result == '"hello, world"\n';
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsonnet-0.22.0.tar.gz.
File metadata
- Download URL: jsonnet-0.22.0.tar.gz
- Upload date:
- Size: 529.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eae5d9bf23c778baad39390f88c13c03b2090dfb5dfa148d6e217df8c1448258
|
|
| MD5 |
75ed8ce173084833f1dab373d000b2e7
|
|
| BLAKE2b-256 |
bd90b35ecd8d60c910874a645d153d4084e07950bc746b4e77dbbe54e199d1cf
|
Provenance
The following attestation bundles were made for jsonnet-0.22.0.tar.gz:
Publisher:
publish-python.yml on google/jsonnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonnet-0.22.0.tar.gz -
Subject digest:
eae5d9bf23c778baad39390f88c13c03b2090dfb5dfa148d6e217df8c1448258 - Sigstore transparency entry: 1173231381
- Sigstore integration time:
-
Permalink:
google/jsonnet@5aec27e03a61dae06461becb95089b15fe217233 -
Branch / Tag:
refs/heads/prepare-release - Owner: https://github.com/google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@5aec27e03a61dae06461becb95089b15fe217233 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jsonnet-0.22.0-cp314-cp314t-win_amd64.whl.
File metadata
- Download URL: jsonnet-0.22.0-cp314-cp314t-win_amd64.whl
- Upload date:
- Size: 315.1 kB
- Tags: CPython 3.14t, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76086435dcfd973252cb3d56b22848009061a44413fa197e15b39decf5400b65
|
|
| MD5 |
cbf4823850d8bf9b1e5fa0676f13b24a
|
|
| BLAKE2b-256 |
c69129d5e9394766e123b42cd23d351b2945117706534a89060241238888d1b6
|
Provenance
The following attestation bundles were made for jsonnet-0.22.0-cp314-cp314t-win_amd64.whl:
Publisher:
publish-python.yml on google/jsonnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonnet-0.22.0-cp314-cp314t-win_amd64.whl -
Subject digest:
76086435dcfd973252cb3d56b22848009061a44413fa197e15b39decf5400b65 - Sigstore transparency entry: 1173232102
- Sigstore integration time:
-
Permalink:
google/jsonnet@5aec27e03a61dae06461becb95089b15fe217233 -
Branch / Tag:
refs/heads/prepare-release - Owner: https://github.com/google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@5aec27e03a61dae06461becb95089b15fe217233 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jsonnet-0.22.0-cp314-cp314t-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: jsonnet-0.22.0-cp314-cp314t-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 7.5 MB
- Tags: CPython 3.14t, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f13c60dc93d682bdcd63f4db368ea6e7e6e9ef9d2efb5bcd1b8dd78818d4fa7d
|
|
| MD5 |
d7f51073b8698055255da5646586b44d
|
|
| BLAKE2b-256 |
b4ee071311a7a9cdc20e817a1419c02db509a829282fe6001dddca33ce7a5e97
|
Provenance
The following attestation bundles were made for jsonnet-0.22.0-cp314-cp314t-musllinux_1_2_x86_64.whl:
Publisher:
publish-python.yml on google/jsonnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonnet-0.22.0-cp314-cp314t-musllinux_1_2_x86_64.whl -
Subject digest:
f13c60dc93d682bdcd63f4db368ea6e7e6e9ef9d2efb5bcd1b8dd78818d4fa7d - Sigstore transparency entry: 1173231833
- Sigstore integration time:
-
Permalink:
google/jsonnet@5aec27e03a61dae06461becb95089b15fe217233 -
Branch / Tag:
refs/heads/prepare-release - Owner: https://github.com/google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@5aec27e03a61dae06461becb95089b15fe217233 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jsonnet-0.22.0-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: jsonnet-0.22.0-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 6.8 MB
- Tags: CPython 3.14t, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f52e8aebcedace2ecc0eeebbd10a18fd3fb2d66ada892acec571a8119eff5087
|
|
| MD5 |
f2adf05bd13dc849418a73191087a740
|
|
| BLAKE2b-256 |
3e08ff983e8161759cfdd393699cc18d80b0391ecd4b21cb839a705a34644516
|
Provenance
The following attestation bundles were made for jsonnet-0.22.0-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
publish-python.yml on google/jsonnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonnet-0.22.0-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
f52e8aebcedace2ecc0eeebbd10a18fd3fb2d66ada892acec571a8119eff5087 - Sigstore transparency entry: 1173231765
- Sigstore integration time:
-
Permalink:
google/jsonnet@5aec27e03a61dae06461becb95089b15fe217233 -
Branch / Tag:
refs/heads/prepare-release - Owner: https://github.com/google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@5aec27e03a61dae06461becb95089b15fe217233 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jsonnet-0.22.0-cp314-cp314t-macosx_11_0_arm64.whl.
File metadata
- Download URL: jsonnet-0.22.0-cp314-cp314t-macosx_11_0_arm64.whl
- Upload date:
- Size: 444.4 kB
- Tags: CPython 3.14t, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
772d6d9e85b7c296d5197b4b48d7fd1b36043c90b80b670e8a769bd21e2b1f25
|
|
| MD5 |
03033b344d1c659e8ec902a11b4b7178
|
|
| BLAKE2b-256 |
348da8534c36284a9c58a60d7be3fc499e9ff226a62631c5b63fb0e0a728a4f3
|
Provenance
The following attestation bundles were made for jsonnet-0.22.0-cp314-cp314t-macosx_11_0_arm64.whl:
Publisher:
publish-python.yml on google/jsonnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonnet-0.22.0-cp314-cp314t-macosx_11_0_arm64.whl -
Subject digest:
772d6d9e85b7c296d5197b4b48d7fd1b36043c90b80b670e8a769bd21e2b1f25 - Sigstore transparency entry: 1173231551
- Sigstore integration time:
-
Permalink:
google/jsonnet@5aec27e03a61dae06461becb95089b15fe217233 -
Branch / Tag:
refs/heads/prepare-release - Owner: https://github.com/google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@5aec27e03a61dae06461becb95089b15fe217233 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jsonnet-0.22.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: jsonnet-0.22.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 305.5 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46df8787b30b001b39d9d551b3d85892d99a699cf3311a63f7bcef080d8a18ff
|
|
| MD5 |
f40ebe6553300df4d6bb10701c5dff70
|
|
| BLAKE2b-256 |
90b191bd98399359b255b906cfce28d898d96d52348e37502859ccb469c083fa
|
Provenance
The following attestation bundles were made for jsonnet-0.22.0-cp38-abi3-win_amd64.whl:
Publisher:
publish-python.yml on google/jsonnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonnet-0.22.0-cp38-abi3-win_amd64.whl -
Subject digest:
46df8787b30b001b39d9d551b3d85892d99a699cf3311a63f7bcef080d8a18ff - Sigstore transparency entry: 1173231661
- Sigstore integration time:
-
Permalink:
google/jsonnet@5aec27e03a61dae06461becb95089b15fe217233 -
Branch / Tag:
refs/heads/prepare-release - Owner: https://github.com/google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@5aec27e03a61dae06461becb95089b15fe217233 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jsonnet-0.22.0-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: jsonnet-0.22.0-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 7.5 MB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aefd2c07038eb9412ae6c46e49b7cfec74f10c53007755b176f7e075e70646f4
|
|
| MD5 |
e1aeb2ff58c218a9bb74db3a9d1d1087
|
|
| BLAKE2b-256 |
bab73270203be535725bf4b1ded5574f07c5cf530a954e2e1b4760efb5bb1e55
|
Provenance
The following attestation bundles were made for jsonnet-0.22.0-cp38-abi3-musllinux_1_2_x86_64.whl:
Publisher:
publish-python.yml on google/jsonnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonnet-0.22.0-cp38-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
aefd2c07038eb9412ae6c46e49b7cfec74f10c53007755b176f7e075e70646f4 - Sigstore transparency entry: 1173232041
- Sigstore integration time:
-
Permalink:
google/jsonnet@5aec27e03a61dae06461becb95089b15fe217233 -
Branch / Tag:
refs/heads/prepare-release - Owner: https://github.com/google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@5aec27e03a61dae06461becb95089b15fe217233 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jsonnet-0.22.0-cp38-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: jsonnet-0.22.0-cp38-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 6.7 MB
- Tags: CPython 3.8+, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1136eefea98f01d654984e868f10faac2749d062464881491ec79ae5c38dc0e
|
|
| MD5 |
ac7c89056fc89be2e89a2fb381541b81
|
|
| BLAKE2b-256 |
689ab1bb5a0ce21a0fc1ace044d28e69003e63f88b15bc22fcb14ca7e74cf63b
|
Provenance
The following attestation bundles were made for jsonnet-0.22.0-cp38-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
publish-python.yml on google/jsonnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonnet-0.22.0-cp38-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
a1136eefea98f01d654984e868f10faac2749d062464881491ec79ae5c38dc0e - Sigstore transparency entry: 1173231930
- Sigstore integration time:
-
Permalink:
google/jsonnet@5aec27e03a61dae06461becb95089b15fe217233 -
Branch / Tag:
refs/heads/prepare-release - Owner: https://github.com/google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@5aec27e03a61dae06461becb95089b15fe217233 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jsonnet-0.22.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: jsonnet-0.22.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 443.4 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42d86e5b2740e31a5e970997d470f517d9073c8a743ddb09ae69069e37529aa6
|
|
| MD5 |
b1493f2674811b7f175a529eea64b77f
|
|
| BLAKE2b-256 |
48b9d0ead4a4a5fbcee2807127aed41063d7482aa969a41d6d6a7c0194cc2686
|
Provenance
The following attestation bundles were made for jsonnet-0.22.0-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
publish-python.yml on google/jsonnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonnet-0.22.0-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
42d86e5b2740e31a5e970997d470f517d9073c8a743ddb09ae69069e37529aa6 - Sigstore transparency entry: 1173231479
- Sigstore integration time:
-
Permalink:
google/jsonnet@5aec27e03a61dae06461becb95089b15fe217233 -
Branch / Tag:
refs/heads/prepare-release - Owner: https://github.com/google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@5aec27e03a61dae06461becb95089b15fe217233 -
Trigger Event:
workflow_dispatch
-
Statement type: