Python dictionary with automatic and arbitrary levels of nestedness
Project description
jict
jict is basically a nested dict.
with some extra features
simple use example :
from jict import jict
jct = jict()
jct['level1']['level2']['level3'] = 'created nested dictionary'
print(jct)
# output :
# {
# "level1": {
# "level2": {
# "level3": "created nested dictionary"
# }
# }
# }
# jict to dict
mydict = jct.dict()
jict utilities:
from jict import jict
# our jict
jct = jict({
'val': { 'list':[ [{ 'find-me': 'secret' }] ] }
})
# we can easly find the key we need
print(jct.get('find-me'))
# we also can rename the keys
# output : secret
jct.rename('find-me','password')
print(jct.get('find-me'))
# output : None
print(jct.get('password'))
# output : secret
# we also can replace values
jct.replace('password','mypass')
print(jct.get('password'))
# output : mypass
def foo(val):
val[0][0]['name'] = 'jict'
return val
# we also can replace with callbacks and multiple values
jct.replace({
'password':'mypass',
'list': foo,
})
# callbacks also work with this: jct.replace('list' , foo)
print(jct.get('list'))
# output: [[{'password': 'mypass', 'name': 'jict'}]]
also you can easly load a .json , .yaml file
from jict import jict
jctj = jict('test.json')
print(jctj)
# output :
# {
# "test": "json-content"
# }
jcty = jict('test.yaml')
print(jctj)
# output :
# {
# "test": "yaml-content"
# }
# if you want to save the modifed values
jctj.save()
jcty.save()
# you can also save to another file
jcty.save('newfile.json')
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
jict-2.5.tar.gz
(8.0 kB
view details)
Built Distribution
jict-2.5-py3-none-any.whl
(8.0 kB
view details)
File details
Details for the file jict-2.5.tar.gz
.
File metadata
- Download URL: jict-2.5.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbeacfc3a807f921aa040a62b6f24dde43a9815cf90e7de306fdfeb8735a8f20 |
|
MD5 | 6609d848a34ce1e869776f9dc1f95f97 |
|
BLAKE2b-256 | 360c2bf60931face070fd8f4c34a3721a3ceb88ba2f307381763d6c8551a3b26 |
File details
Details for the file jict-2.5-py3-none-any.whl
.
File metadata
- Download URL: jict-2.5-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22c1273ed0cc320bc8cc6e3c2308aab0d22fc0003d1df3254b23549eb092aed5 |
|
MD5 | 4b72ff42c96d76c127e75ab38ff2f918 |
|
BLAKE2b-256 | ef64a03415be131046510e8ce5e43316d38948de1a5cf7e41eea819f6a26dd27 |