https://github.com/fiverr/pyresolve
Resolve dot notation from dictionary
https://github.com/fiverr/pyresolve
dictionary dot-notation python resolve
Last synced: about 1 month ago
JSON representation
Resolve dot notation from dictionary
- Host: GitHub
- URL: https://github.com/fiverr/pyresolve
- Owner: fiverr
- License: mit
- Created: 2020-06-23T21:09:54.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-10T10:37:24.000Z (11 months ago)
- Last Synced: 2025-04-14T07:02:59.600Z (about 2 months ago)
- Topics: dictionary, dot-notation, python, resolve
- Language: Python
- Homepage: https://pypi.org/project/pyresolve/
- Size: 12.7 KB
- Stars: 4
- Watchers: 9
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pyresolve [](https://pypi.org/project/pyresolve/) [](https://github.com/fiverr/pyresolve) [](https://circleci.com/gh/fiverr/pyresolve)
Resolve dot notation from dictionary
```py
from pyresolve import resolvemy_dictionary = {"out":{"middle":{"in":"Balue"}}}
# Before
my_dictionary.get('out', {}).get('middle', {}).get('in')# After
resolve(my_dictionary, "out.middle.in") # "Balue"
```Does not break for missing properties
```py
resolve(my_dictionary, "outer.missing.something") # None
```Can specify a different default value
```py
resolve(my_dictionary, "outer.missing.something", []) # []
```Supports index in list
```py
dictionary_with_list = {"users": [{"name":"Joe"}, {"name":"Jane"}]}
resolve(my_dictionary, "users.1.name") # Jane
```Supports list notation
```py
dictionary_with_list = {"users": [{"name":"Joe"}, {"name":"Jane"}]}
resolve(my_dictionary, "users[1].name") # Jane
```Install
```bash
pip install pyresolve
```