json-templates
A small python module for populating json template files.
Version 0.1.0
Accepts either a json string or a file path and a dictionary. json-template replaces the place holders found in the json with those found in the dictionary.
Below is a template example
{
"key":"hard coded value",
"key2":1,
"key3":"{{ variable }}",
"key4":"{% array %}"
}
Currently supports {{ variable }} for single replacement and {% array %} for iterable replacement.
For example given the following dictionary
{
"variable":"hello world",
"array":["foo","bar"]
}
The JSON would become
{
"key":"hard coded value",
"key2":1,
"key3":"hello world",
"key4":["foo","bar"]
}
Usage
import JsonTemplates
json_tmp = JsonTemplates()
result = json_tmp.load("template.json")
if result[0]:
new_dict = json_tmp.generate({"variable":"hello world","array":["foo","bar"]})
Methods
-
load(json_file_path) - Loads a JSON file
Returns a tuple (Success,error message or dictionary) -
loads(json_str) - Loads a JSON string
Returns a tuple (Success,error message or dictionary) -
generate(replacement_dict) - Takes in a dictionary of replacement values and generates a new dictionary with the placeholders replaced with the values in the dictionary
Returns a tuple (Success, error message or dictionary)
Metadata
Release files for jsontemplates 0.1.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 |
|---|---|---|---|---|
| jsontemplates-0.1.0.tar.gz | 4.0 kB | Without provenance | Details for jsontemplates-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsontemplates-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for jsontemplates-0.1.0-py3-none-any.whl |
Total release size: 7.6 kB
Release files / jsontemplates-0.1.0.tar.gz
| Download URL | jsontemplates-0.1.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1f06186341c98d964b81d105c0ad615638df5882f593c265f6581eddf9a2a6b
|
|
BLAKE2b-256 checksum How to use checksums |
c63cd1acbe78c9aa032dd93b45023dd8b23ad29c44bca2a99d0b1ba2417cab4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.2
|
Release files / jsontemplates-0.1.0-py3-none-any.whl
| Download URL | jsontemplates-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e858df2803304a226f47109791d3582c934652ba7930176e40ec659a4c3373f
|
|
BLAKE2b-256 checksum How to use checksums |
2f7ad78588fdb0c1a38f4c97996127748e7aacc8bfa994f80650de243f001a23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.2
|
Security for jsontemplates 0.1.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.