Skip to main content

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

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

jsontas-1.0.0.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

jsontas-1.0.0-py2.py3-none-any.whl (27.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file jsontas-1.0.0.tar.gz.

File metadata

  • Download URL: jsontas-1.0.0.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.3

File hashes

Hashes for jsontas-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8057a19a2aca7f8ca9bfbaabe096a7b587796cfaf9270d02f3a84293b5fbcf13
MD5 cdce3a1af5389154e42f012456943bd0
BLAKE2b-256 2bdaf223895fb8285b870ca5fcac8fcc6e40f176ed5ce1dae594f7084f03d4fa

See more details on using hashes here.

File details

Details for the file jsontas-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: jsontas-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.3

File hashes

Hashes for jsontas-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5d15e86985400bf242b7da05a9d4f2c8d9f8113c70a2e4d28a163a593ebaaf8a
MD5 7299bafc9e67997f7389d357ad0a2889
BLAKE2b-256 9104c992aa5a8da17daa49e62ec3977bc6e52c58884e204368ed401f4a0d0635

See more details on using hashes here.

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