Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jict-3.0.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

jict-3.0.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file jict-3.0.0.tar.gz.

File metadata

  • Download URL: jict-3.0.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.32.3 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for jict-3.0.0.tar.gz
Algorithm Hash digest
SHA256 1257d804868c0e20ecac79dc02c107d996aeb45acec5755742a169baa83f6ffb
MD5 4137adf034e56ae4fbd68cfaa4a49a5d
BLAKE2b-256 25bec0760f55a2bea019ccb5c57016b48ae891d35ff1391446d920d61d02d046

See more details on using hashes here.

File details

Details for the file jict-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: jict-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.32.3 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for jict-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4d461a9dcae97df90c764b422671ef4ca0c04d90a2081fb3a8aff5dc3046677
MD5 5866c448daa7703b21c4d561e0541bdd
BLAKE2b-256 f6e172fda10d30669d3399cfa52909d5d59610304d7a7ee534581de32793bc38

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page