An Easier Way to work with json files
Project description
Config-Json
An Easier Way to work with JSON configs
this library provide some top level method to make it easy to work with json
- How to Use?
from jconf.config import Config
# u can either do
c = Config(config_name="main.json") # default name is main.json
# or
with Config(config_name="main.json") as c:
pass
- functions available
from jconf.config import Config
c = Config(config_name="main.json")
# returns all the keys from a json file
c.keys()
# returns all the values from a json file
c.values()
# gets the key from a json file
c.get('car')
# deletes a key from a json file
c.delete('car')
# update a value in a json file
c.update('car', 'tesla')
# sets a new key in json file
c.set('car2', 'ferari')
- instead of using functions you can also use:
from jconf.config import Config
c = Config('main.json')
# to/set or change a value
c['car'] = "name"
c['number_plate'] = ['3131', '3134', '3132']
# delete a key
del c['car']
# loop over a json file
for i in c:
print(i) # returns a list of tuple with (key, value)
# updates / add to an existing key
c['car'] += {'model', 'year'}
# get a value
car = c['car']
- Automatically creates the passed config_name if it doesn't exists
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
config-json-0.0.1.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for config_json-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ceaa408b01918054311cc289477649ac7989cc9bea34f969c670f84c78d0b9d |
|
MD5 | 439ba8f3a921facd582a0b67195b0057 |
|
BLAKE2b-256 | fcc07c20d5739a12954421a6b507d07b19899a8afa5c0638a1407e7c5cf08b05 |