Jsoninja
A library that allows you to generate JSON's from
templates written with Python data types.
Instalation
$ pip install jsoninja
Use Case Examples
You can use the main Python data types:
import jsoninja
template = {
"foo": "{{variable_name}}",
}
replacements = {
"variable_name": "bar",
}
result = jsoninja.replace(template, replacements)
# {
# "foo": "bar",
# }
Allows multiple replacements of the same variable:
import jsoninja
template = {
"message1": "{{message}}",
"message2": "{{message}}",
"message3": "{{message}}",
}
replacements = {
"message": "I am duplicated!",
}
result = jsoninja.replace(template, replacements)
# {
# "message1": "I am duplicated!",
# "message2": "I am duplicated!",
# "message3": "I am duplicated!",
# }
Use callback functions to generate the values to be replaced:
import jsoninja
def generate_password() -> str:
return "super_secret_password"
template = {
"password": "{{password}}",
}
replacements = {
"password": generate_password,
}
result = jsoninja.replace(template, replacements)
# {
# "password": "super_secret_password",
# }
Support for variables in the dict keys (replacements must be str, int, float or bool):
import jsoninja
template = {
"{{variable_name}}": "bar",
}
replacements = {
"variable_name": "foo",
}
result = jsoninja.replace(template, replacements)
# {
# "foo": "bar",
# }
If you want to use a custom variable pattern, you can do that too:
from jsoninja import Jsoninja
# The pattern must include a capturing group for the variable name.
pattern = r"\$\{([a-zA-Z0-9_]+)\}"
jsoninja = Jsoninja(variable_pattern=pattern)
template = {
"foo": "${variable_name}",
}
replacements = {
"variable_name": "bar",
}
result = jsoninja.replace(template, replacements)
# {
# "foo": "bar",
# }
Metadata
Release files for jsoninja 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsoninja-1.2.0.tar.gz | 35.7 kB | Without provenance | Details for jsoninja-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsoninja-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for jsoninja-1.2.0-py3-none-any.whl |
Total release size: 41.1 kB
Release files / jsoninja-1.2.0.tar.gz
| Download URL | jsoninja-1.2.0.tar.gz |
|---|---|
| Size | 35.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d142b85559e013febc0ad546a73cffafdb20db6d3d4d7febf675cd14b43b68d1
|
|
BLAKE2b-256 checksum How to use checksums |
dbd67f55aa7a4c586796d38723713ba0c598cf80719ea9328467ef3c5ad9e44a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / jsoninja-1.2.0-py3-none-any.whl
| Download URL | jsoninja-1.2.0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ae07026dc1f67f64b7fa255bd5fe58e9fccc0ce0cd2b4c7c33c45dea1afd3df
|
|
BLAKE2b-256 checksum How to use checksums |
fbf283440b956109b0b39fd062c7f70eaac188ad41b254cc215f8cadd349e55c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for jsoninja 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.