JSONTas is a tool for generating dynamic JSON structures.
Project description
JSONTas is a tool for generating dynamic JSON data.
Description
JSONTas adds conditionals and logic to JSON files in order to create dynamic JSON data depending on which dataset you supply.
It opens up the possibility to create generic tools where most of the operations are done by executing JSONTas on the data.
Documentation: https://jsontas.readthedocs.io/en/latest
Features
Simple yet powerful syntax.
HTTP requests on parse
Separation of environments by providing different datasets.
Installation
Install the project by running:
pip install jsontas
Examples
First we create two datasets. One for our ‘dev’ environment and one for our ‘prod’ environment.
Dataset ‘dev.json’
{
"mode": "dev",
"database": "dev_db"
}
Dataset ‘prod.json’
{
"mode": "prod",
"database": "prod_db"
}
JSONTas JSON file
Next up, let’s create our JSONTas file.
{
"database": {
"host": "myawesomedb.example.com",
"database": "$database"
},
"message": {
"$condition": {
"if": {
"key": "$mode",
"operator": "$eq",
"value": "dev"
},
"then": "This is the DEV server.",
"else": "This is the PROD server."
}
}
}
JSONTas execute with ‘dev’ dataset
jsontas -d dev.json data.json
{
"database": {
"host": "myawesomedb.example.com",
"database": "dev_db"
},
"message": "This is the DEV server."
}
JSONTas execute with ‘prod’ dataset
jsontas -d prod.json data.json
{
"database": {
"host": "myawesomedb.example.com",
"database": "prod_db"
},
"message": "This is the PROD server."
}
These examples only show the bare minimum. For more examples look at our documentation at: https://jsontas.readthedocs.io/en/latest
Contribute
Issue Tracker: https://github.com/AxisCommunications/jsontas/issues
Source Code: https://github.com/AxisCommunications/jsontas
Support
If you are having issues, please let us know. Email tobias.persson@axis.com or just write an issue.
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
Built Distribution
File details
Details for the file jsontas-1.4.0.tar.gz
.
File metadata
- Download URL: jsontas-1.4.0.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bc14b8a85358310b97c06dbeaa51f4cc5e0808f53641d7c987c511096084b8a |
|
MD5 | 11f42ec376b2a22f15eb2b006de08af9 |
|
BLAKE2b-256 | 5fb33dd6b70f3e2a31dde835caf41b035b9a0a467d8c6ad37d884bf5d1d8a725 |
File details
Details for the file jsontas-1.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: jsontas-1.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31e1bc6904ff84f63279220b01b7b39227b1e9b33cc259540cd4714a840dd136 |
|
MD5 | 8935630637ba2b1f2ec34461086b06d7 |
|
BLAKE2b-256 | 7ec23f197c23ffa0546314b7e64f13871dc7a8df5f0e724a5e172d565aa9ea67 |