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.4.2.tar.gz
(6.2 kB
view details)
Built Distribution
jict-2.4.2-py3-none-any.whl
(7.1 kB
view details)
File details
Details for the file jict-2.4.2.tar.gz
.
File metadata
- Download URL: jict-2.4.2.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 470d6841e0384847793af3121f4bb64bb5c88ac9df7b61fad1a6346e1a46e2db |
|
MD5 | 1d50177240ebb47b73cdc148e905e257 |
|
BLAKE2b-256 | f3c4468fbfad7cfe76986dc0db3d446a99429f64a0df71db713114afcfcd2676 |
File details
Details for the file jict-2.4.2-py3-none-any.whl
.
File metadata
- Download URL: jict-2.4.2-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b529214a2fa9f0a280a0143d7dd896d3d3311d0983e754b428da01bd539755b5 |
|
MD5 | 089aa1eea9e270bb0c8064f8931c56e7 |
|
BLAKE2b-256 | 324342d9836114426d48285da240b87d56e731ca371e84c0a11be0b987c67fa7 |