Simple JSON configuration file parser with easy access for structured data
Project description
varjson
varjson addresses a straightforward challenge: incorporating values from environment variables into JSON configuration files. This functionality is akin to envyaml <https://github.com/thesimj/envyaml>_ and varyaml <https://github.com/abe-winter/varyaml>_, which offer similar capabilities for YAML, and has significantly inspired this package.
Example
Consider the following configuration saved in config.json:
{
"db": {
"host": "$DB_HOST",
"port": "$DB_PORT",
"username": "$DB_USERNAME",
"password": "$DB_PASSWORD",
"name": "my_database"
}
}
With the environment variables set as follows:
DB_HOST=some-host.tld
DB_PORT=3306
DB_USERNAME=user01
DB_PASSWORD=veryToughPas$w0rd
This configuration can then be parsed using varjson like this:
from varjson import EnvJSON
cfg = EnvJSON(json_file="./config.json", strict=True)
print(cfg)
# {'db': {'host': 'some-host.tld',
# 'port': 3306,
# 'username': 'user01',
# 'password': 'veryToughPas$w0rd',
# 'name': 'my_database'}}
Tests
License
Licensed under the MIT license (see LICENSE <./LICENSE>_ file for more details).
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 Distribution
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 varjson-0.1.0.tar.gz.
File metadata
- Download URL: varjson-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eeafeb33af4da01d96ffa4c74a7e5bad38121332bc572b114478f4c2e0c252e2
|
|
| MD5 |
e6bdcf7c83057721d667c034b0a80220
|
|
| BLAKE2b-256 |
0b762dd7800534b176384b1c34890a680fb27fbd8a5be7b801af0c1ccf901bd5
|
File details
Details for the file varjson-0.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: varjson-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c48f2a813b6fb66043c03dd1abafe4bbe04c3f837eb7d824f62da4cc60b8bf8f
|
|
| MD5 |
7466bbcb500a702717832dd08dec49db
|
|
| BLAKE2b-256 |
f635ec1d711f4a5ba487d1d2136fa25338972d0388dfb601d3ca3eb2d33311c4
|