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.6.tar.gz
(8.7 kB
view details)
Built Distribution
jict-2.6-py3-none-any.whl
(8.4 kB
view details)
File details
Details for the file jict-2.6.tar.gz
.
File metadata
- Download URL: jict-2.6.tar.gz
- Upload date:
- Size: 8.7 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 | 2cf40e819e25691b203549d5e6d681c24183583da081d877c06e4cbf4ced9fe1 |
|
MD5 | 89b3d506d839b4a0eee0e5f118d11d7e |
|
BLAKE2b-256 | 8a52069256c4b7bc095a9fa10484a9c70234d8b3737ff33677ede52bc7e94098 |
File details
Details for the file jict-2.6-py3-none-any.whl
.
File metadata
- Download URL: jict-2.6-py3-none-any.whl
- Upload date:
- Size: 8.4 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 | 5b097b03ed287ff9e05913cb6d1b643e94c090d3ee32a1d7b2d96b522687d6c4 |
|
MD5 | cb2a573f959e55f04ee62e29f613fd19 |
|
BLAKE2b-256 | 9979dc6c3d79e17d8ec5ffee7d48bd362b13d1dd69d017b64535fc4a897ebb6b |